我正在使用我在Interface Builder中创建的自定义单元格创建一个uitableview。目前有三个单元格(UITableViewCell)。
我在视图上有一个UITableView。
我的代码是相当标准的,但我无法弄清楚如何实际显示三个自定义单元格。我正在使用cellForRowAtIndexPath方法。
我的目标是获得一个分组的uitableview,其显示如下
Item
- Name
Settings
- alert
- time
所以上面的缩进视图应该是我的分组uitableview。问题是,我无法使用代码显示它。 uitableview将永远是这样。我试图复制设置样式屏幕...所以我没有任何数组来显示uitableview单元格。
我如何实际展示我的三个细胞?我有以下代码
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 2;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if (section == 0)
return 1;
else
return 2;
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
if(section == 0)
return @"Item";
else
return @"Settings";
}
所以我需要知道的是如何在tableview中实际显示我的自定义单元格! 感谢您提供任何信息。我在谷歌搜索了AGES ..所有教程都使用数组来显示数据!
答案 0 :(得分:0)
你会踢自己。
在cellForRow中,使用一些级联if语句,例如:
if (indexPath.section == 0) {
cell.textLabel.text = @"Name";
} else {
if (indexPath.row == 0) {
cell.textLabel.text = @"alert";
} else {
cell.textLabel.text = @"time";
}
}