nev*_*ing 1 iphone objective-c uitableview
我UITableViewCell用这段代码创建了一个拼写错误:
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"CellIdentifier";
UITableViewCell *cell = [self.tableView
dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSLog(@"Creating cell");
cell = [[[UITableViewCell alloc]
initWithStyle:UITableViewStylePlain
reuseIdentifier:CellIdentifier] autorelease];
}
cell.textLabel.text = @"Hello";
return cell;
}
Run Code Online (Sandbox Code Playgroud)
错字是用UITableViewStylePlain而不是UITableViewCellStyleDefault.代码工作正常,创建新单元格.为什么?
kub*_*ubi 10
这就是定义这些变量的方式.
typedef enum {
UITableViewCellStyleDefault,
UITableViewCellStyleValue1,
UITableViewCellStyleValue2,
UITableViewCellStyleSubtitle
} UITableViewCellStyle;
typedef enum {
UITableViewStylePlain,
UITableViewStyleGrouped
} UITableViewStyle;
Run Code Online (Sandbox Code Playgroud)
双方UITableViewCellStyleDefault并UITableViewStylePlain评估为0,所以他们互换.
| 归档时间: |
|
| 查看次数: |
357 次 |
| 最近记录: |