xcode cell.detailTextLabel.text 不起作用...为什么
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2349279/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
cell.detailTextLabel.text not working... why
提问by user278859
Using the following code I am getting the text.label but not the detailTextLabel.text. The NSLog is displaying correctly.
使用下面的代码,我得到了 text.label 但不是 detailTextLabel.text。NSLog 显示正确。
cell.textLabel.text = [eventLabels objectAtIndex:indexPath.row];
cell.detailTextLabel.text = [eventFields objectAtIndex:indexPath.row]];
NSLog(@"%@", [eventFields objectAtIndex:indexPath.row]);
I also tried...
我也试过...
cell.detailTextLabel.text = [NSString stringWithFormat:@"%@", [eventFields objectAtIndex:indexPath.row]];
I have not had problems with this before. Any suggestions?
我以前没有遇到过这个问题。有什么建议?
John
约翰
回答by jbrennan
Make sure you're using an appropriate UITableViewCellStyle
with this (anything but UITableViewCellStyleDefault
should thus work). The cell's style is specified when you initialize it.
确保您使用的是适当的UITableViewCellStyle
(任何但UITableViewCellStyleDefault
应该有效的)。单元格的样式是在初始化时指定的。
回答by Kamille
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle
reuseIdentifier:CellIdentifier] autorelease];
}
Do remember to change to UITableViewCellStyleSubtitle
记得改成UITableViewCellStyleSubtitle
回答by Erhan Demirci
If you choose style UITableViewCellStyleSubtitle
, your detailTextLabel.text
will show
如果你选择风格UITableViewCellStyleSubtitle
,你detailTextLabel.text
会展示
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle
reuseIdentifier:CellIdentifier] ;