【发布时间】:2013-09-10 17:33:02
【问题描述】:
命令 cell.textLabel.text 和 cell.detailTextLabel.text 在控制台中提供输出,但在模拟器上的表格视图中没有给出任何值...
这是生成我用过的单元格的代码..
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"bookCell";
UITableViewCell *cell;
cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
cell=[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
// Book *bookDetail=[booksArrayDataSource objectAtIndex:indexPath.row];
cell.accessoryType=UITableViewCellAccessoryDetailDisclosureButton;
cell.textLabel.text= [self titleForRow:indexPath];
NSLog(@"title for row= %@", cell.textLabel.text);
cell.detailTextLabel.text= [self subtitleForRow:indexPath];
NSLog(@"subtitle for row= %@",cell.detailTextLabel.text);
return cell;
}
【问题讨论】:
-
像这样用 [NSString stringWithFormat:@"%@",[self titleForRow:indexPath]] 测试。
-
尝试应用一些颜色和字体...
-
使用 titleForRow 和 subtitleForRow 方法更新您的查询。
-
嘿 Ganapathy 他们工作正常..因为控制台显示 NSLog(@"title for row= %@", cell.textLabel.text);NSLog(@"subtitle for row= % @",cell.detailTextLabel.text);显示标题和副标题已正确设置...但是在模拟器上看不到它们...
-
检查一次委托方法。行数和没有。选择是否正确返回。
标签: ios objective-c uitableview