![](/img/trans.png)
[英]In UITableView, cell.detailTextLabel.text isn't working… why?
[英]cell.detailTextLabel.text not working… why
使用以下代碼,我得到了text.label而不是detailTextLabel.text。 NSLog顯示正確。
cell.textLabel.text = [eventLabels objectAtIndex:indexPath.row];
cell.detailTextLabel.text = [eventFields objectAtIndex:indexPath.row]];
NSLog(@"%@", [eventFields objectAtIndex:indexPath.row]);
我也嘗試過...
cell.detailTextLabel.text = [NSString stringWithFormat:@"%@", [eventFields objectAtIndex:indexPath.row]];
我以前沒有這個問題。 有什么建議么?
約翰
確保與此配合使用了合適的UITableViewCellStyle
(因此,除了UITableViewCellStyleDefault
任何東西都應該可以使用)。 初始化時指定單元格的樣式。
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle
reuseIdentifier:CellIdentifier] autorelease];
}
切記更改為UITableViewCellStyleSubtitle
如果選擇樣式UITableViewCellStyleSubtitle
,則detailTextLabel.text
將顯示
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle
reuseIdentifier:CellIdentifier] ;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.