UITableView 将数组对象放入部分
嘿伙计们,我需要知道谁将这些数组对象放入两个单独的部分,这意味着一个部分用于红色单元格,另一个部分用于蓝色单元格。非常感谢您一整天都在这方面的帮助。这是我的代码:
-(void)viewDidLoad {
[super viewDidLoad];
//Initialize the array.
array = [[NSMutableArray alloc] init];
[array addObject:@"Red"];
[array addObject:@"Blue"];
self.ViewTable.backgroundColor = [UIColor clearColor];
}
Hey guys I need to know who to put these array objects into two separate sections, that means one section for the red cell and another section for the blue cell. Would really appreciate your help been stuck on this all day now. Here is my code:
-(void)viewDidLoad {
[super viewDidLoad];
//Initialize the array.
array = [[NSMutableArray alloc] init];
[array addObject:@"Red"];
[array addObject:@"Blue"];
self.ViewTable.backgroundColor = [UIColor clearColor];
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要实现:
返回部分数:
返回请求部分的行数
通过读取indexPath.row 和indexPath.section 返回正确的单元
格因此,对于红色,您将查找indexPath.section 等于0 的单元格请求,并且indexPath.row 等于 0。蓝色表示 indexPath.section 等于 1,indexPath.row 等于 0
You need to implement:
return number of sections:
return number of rows for the requested section
return correct cell by reading both indexPath.row and indexPath.section
So for red you would look for a cell request that has indexPath.section equal to 0 and indexPath.row equal to 0. blue would be indexPath.section equal to 1 and indexPath.row equal to 0
更新:
在cellForRowAtIndexPath中
Updated:
In the
cellForRowAtIndexPath