我正在尝试在UITableViewCell上设置字幕标签。我有一个包含标题和字幕对的字典,键列表存储在self.results中。但是,当我使用以下代码运行时:
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Search Result Cell" forIndexPath:indexPath];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Search Result Cell"];
}
cell.textLabel.text = [self.results objectAtIndex:indexPath.row];
cell.detailTextLabel.text = self.resultPairs[[self.results objectAtIndex:indexPath.row]];
NSLog(@"%@", self.resultPairs[cell.textLabel.text]);字幕仍为空白,但NSLog打印正确的输出。这里发生什么事情?当我将detailTextLabel设置为常量时,它工作得很好。
发布于 2014-12-07 08:50:43
解决方案是字符串包含初始空格的分配,导致它们被填充到视图之外。
发布于 2014-12-06 13:20:36
问题是默认的单元格样式不包括字幕。如果使用情节提要,只需在Interface中将样式设置为字幕即可。
https://stackoverflow.com/questions/27331997
复制相似问题