#import "FourViewController.h"@interface FourViewController (){
UITableView *tv;? ? //表格
NSArray *arr3;
NSArray *arr2;
NSArray *arr1;
NSArray *arr4;
}
@end
@implementation FourViewController
- (void)viewDidLoad {
[super viewDidLoad];
//創(chuàng)建表格
tv = [[UITableView alloc]initWithFrame:self.view.frame style:UITableViewStyleGrouped];
//設(shè)置代理
tv.delegate = self;
tv.dataSource = self;
[self.view addSubview:tv];
arr2 = [NSArray arrayWithObjects:@"收藏",@"相冊(cè)",@"卡包",@"表情", nil];
arr1 = [NSArray arrayWithObjects:@"錢包", nil];
arr3 = [NSArray arrayWithObjects:@"設(shè)置", nil];
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 4;
}
//設(shè)置行數(shù)
-(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;
}
//設(shè)置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)
{
//設(shè)置標(biāo)題
cell.textLabel.text = @"大晨哥";
//設(shè)置標(biāo)題字體
cell.textLabel.font = [UIFont systemFontOfSize:25];
//設(shè)置子標(biāo)題
cell.detailTextLabel.text = @"微信號(hào):13464577730";
cell.detailTextLabel.font = [UIFont systemFontOfSize:15];
cell.detailTextLabel.backgroundColor = [UIColor lightGrayColor];
//設(shè)置顏色
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;
}