【发布时间】:2014-02-10 18:14:10
【问题描述】:
我有一个 UITableView,我正在加载数据。标题显示正常,但 cell.textlabel.text 没有显示任何内容。 (注意点击时颜色不是白色,它也不会显示)但是我可以在 AlertView 中获取cell.textlabel.text 的值。
有什么帮助吗??
代码:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"cellT";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
cell.textLabel.text = [[theTArray objectAtIndex:indexPath.section]objectAtIndex:0];
// Configure the cell...
cell.textLabel.textColor = [UIColor blackColor];
return cell;
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
return [[theTArray objectAtIndex:section]objectAtIndex:1];
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
NSString *message = [NSString stringWithFormat:@"%@", cell.textLabel.text];
NSString *title = [[theTArray objectAtIndex:indexPath.section]objectAtIndex:1];
UIAlertView *theAlert = [[UIAlertView alloc] initWithTitle:title message:message delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[tableView reloadData];
[theAlert show];
}
【问题讨论】:
标签: ios objective-c uitableview xcode5