【发布时间】:2013-08-23 01:58:15
【问题描述】:
当我使用下面的sn-p时,详细文本标签不显示:
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString* cellIdentifier = @"NEW";
[self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:cellIdentifier];
UITableViewCell* cell = [self.tableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath ];
if(cell==nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier];
}
NSDictionary* item = [saleItems objectAtIndex:[indexPath row]];
cell.textLabel.text = [item valueForKey:@"name"];
cell.detailTextLabel.text = [item valueForKey:@"store"];
return cell;
}
但是,当我将上述方法修改为以下详细信息时:
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString* cellIdentifier = @"NEW";
[self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:cellIdentifier];
UITableViewCell* cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier];
NSDictionary* item = [saleItems objectAtIndex:[indexPath row]];
cell.textLabel.text = [item valueForKey:@"name"];
cell.detailTextLabel.text = [item valueForKey:@"store"];
return cell;
}
第一种方法出了什么问题? 使用 dequeueReusableCellWithIdentifier 的正确方法是什么?
【问题讨论】:
标签: ios uitableview uikit