微信我的
#import "FourViewController.h"@interface FourViewController (){
UITableView *tv; //表格
NSArray *arr3;
NSArray *arr2;
NSArray *arr1;
NSArray *arr4;
}
@end
@implementation FourViewController
- (void)viewDidLoad {
[super viewDidLoad];
//创建表格
tv = [[UITableView alloc]initWithFrame:self.view.frame style:UITableViewStyleGrouped];
//设置代理
tv.delegate = self;
tv.dataSource = self;
[self.view addSubview:tv];
arr2 = [NSArray arrayWithObjects:@"收藏",@"相册",@"卡包",@"表情", nil];
arr1 = [NSArray arrayWithObjects:@"钱包", nil];
arr3 = [NSArray arrayWithObjects:@"设置", nil];
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 4;
}
//设置行数
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if (section == 0)
{
return 1;
}
else if (section == 1)
{
return 1;
}
else if (section == 2)
{
return 4;
}
else
{
return 1;
}
return 0;
}
//设置cell
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *reuseID = @"cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuseID];
if (indexPath.section == 0)
{
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:reuseID];
tv.rowHeight = 150;
}
else
{
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:reuseID];
tv.rowHeight = 40;
}
if (indexPath.section == 0)
{
//设置标题
cell.textLabel.text = @"大晨哥";
//设置标题字体
cell.textLabel.font = [UIFont systemFontOfSize:25];
//设置子标题
cell.detailTextLabel.text = @"微信号:13464577730";
cell.detailTextLabel.font = [UIFont systemFontOfSize:15];
cell.detailTextLabel.backgroundColor = [UIColor lightGrayColor];
//设置颜色
cell.detailTextLabel.backgroundColor = [UIColor lightGrayColor];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
else if (indexPath.section == 1)
{
cell.textLabel.text = arr1[indexPath.row];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
else if (indexPath.section == 2)
{
cell.textLabel.text = arr2[indexPath.row];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
else if (indexPath.section == 3)
{
cell.textLabel.text = arr3[indexPath.row];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
return cell;
}