Model *m=[[Model alloc]init];
m.zhu=@"第几季理解";
m.fu=@"同户名:137123";
m.ima=@"1111";
Model *m1=[[Model alloc]init];
m1.zhu=@"人脉商圈";
Model *m2=[[Model alloc]init];
m2.zhu=@"收藏";
Model *m3=[[Model alloc]init];
m3.zhu=@"钱包";
m3.ima=@"7";
Model *m4=[[Model alloc]init];
m4.zhu=@"勋章墙";
Model *m5=[[Model alloc]init];
m5.zhu=@"收益(元)";
Model *m6=[[Model alloc]init];
m6.zhu=@"金币余额";
Model *m7=[[Model alloc]init];
m7.zhu=@"浏览记录";
arr1=@[m];
arr2=@[m1,m2];
arr3=@[m3,m4];
arr4=@[m5,m6,m7];
//创建表格
tab=[[UITableView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) style:UITableViewStyleGrouped];
tab.delegate=self;
tab.dataSource=self;
[self.view addSubview:tab];
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 5;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if (section ==0)
{
return arr1.count;
}
else if (section == 1)
{
return arr2.count;
}
else if (section == 2)
{
return arr3.count;
}
else if (section == 3)
{
return arr4.count;
}
return 0;
}
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *str=@"cell";
UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:str];
if (cell==nil)
{
cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:str];
}
cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
//赋值
if (indexPath.section ==0)
{
Model *m=arr1[indexPath.row];
cell.textLabel.text=m.zhu;
cell.detailTextLabel.text=m.fu;
cell.imageView.image=[UIImage imageNamed:m.ima];
}
else if (indexPath.section ==1)
{
Model *m1=arr2[indexPath.row];
cell.textLabel.text=m1.zhu;
cell.detailTextLabel.text=m1.fu;
cell.imageView.image=[UIImage imageNamed:m1.ima];
}
else if (indexPath.section ==2)
{
Model *m1=arr3[indexPath.row];
cell.textLabel.text=m1.zhu;
cell.detailTextLabel.text=m1.fu;
cell.imageView.image=[UIImage imageNamed:m1.ima];
}
else if (indexPath.section ==3)
{
Model *m2=arr4[indexPath.row];
cell.textLabel.text=m2.zhu;
cell.detailTextLabel.text=m2.fu;
cell.imageView.image=[UIImage imageNamed:m2.ima];
}
else if (indexPath.section ==4)
{
Model *m3=arr5[indexPath.row];
cell.textLabel.text=m3.zhu;
cell.detailTextLabel.text=m3.fu;
cell.imageView.image=[UIImage imageNamed:m3.ima];
}
return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section==0)
{
}
else if (indexPath.section==1)
{
if (indexPath.row==0)
{
}
if (indexPath.row==1)
{
}
}
else if (indexPath.section==2)
{
}
else if (indexPath.section==3)
{
NSLog(@"3");
}
else if (indexPath.section==4)
{
NSLog(@"4");
}
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section ==0)
{
return 90;
}
return 44;
}
网友评论