自定义单元格uitableview - 无法显示所有行
问题描述:
我使用在Interface Builder中创建的自定义单元格创建了uitableview。目前有三个单元格(UITableViewCell)。自定义单元格uitableview - 无法显示所有行
我有一个在视图上的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 ..所有的教程使用数组来显示数据!
答
你会踢你自己。
在cellForRow,使用if语句一些级联,如:
if (indexPath.section == 0) {
cell.textLabel.text = @"Name";
} else {
if (indexPath.row == 0) {
cell.textLabel.text = @"alert";
} else {
cell.textLabel.text = @"time";
}
}
WOW。不能相信这就是所需要的!谢谢!! *踢自己* – 2010-04-10 19:16:55