ElP*_*ter 4 xcode objective-c uitableview ios
使用Xcode 4.6,我试图显示一个典型的UITableView及其带字幕的单元格.
如果我没错,代码是这样的:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
Test *myTest = [self listTests][indexPath.row];
cell.textLabel.text = [myTest name];
UIFont *cellFont = [UIFont systemFontOfSize:16.0];
cell.textLabel.font = cellFont;
UIFont *detailFont = [UIFont systemFontOfSize:12.0];
NSMutableString *detailText = [NSMutableString stringWithFormat:@"%d", [myTest numQuestions]];
[detailText appendString:@" preguntas."];
cell.detailTextLabel.text = detailText;
cell.detailTextLabel.font = detailFont;
return cell;
Run Code Online (Sandbox Code Playgroud)
}
出于某种原因,它永远不会通过这行代码:
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
Run Code Online (Sandbox Code Playgroud)
因此,细胞永远不会被初始化UITableViewCellStyleSubtitle.
在做的时候,它总是从最初开始就是一个有效的细胞 [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
我能做错什么?
真的很难受.我总是使用这个代码,它通常有效.我还能在其他地方做错什么?
| 归档时间: |
|
| 查看次数: |
2377 次 |
| 最近记录: |