如何从didSelectRowAtIndexPath访问UITableView部分标签

时间:2012-04-21 23:34:03

标签: xcode tableview sections

在我的tableView didSelectRowAtIndexPath中,我可以访问单元格textLabel。如何访问部分标签?

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    topPlacesAppDelegate *appDelegate = (topPlacesAppDelegate *) [[UIApplication sharedApplication] delegate];  
    appDelegate.chosenPhoto = [self.topPlaces objectAtIndex:indexPath.row];  
. . . 
    UITableViewCell *mycell = [tableView cellForRowAtIndexPath:indexPath];
    NSLog(@"   indexPath.section / Row = %i / %i", indexPath.section, indexPath.row);
    NSLog(@"   textLabel.text          = %@", mycell.textLabel.text);
    NSLog(@"   detailTextLabel.text    = %@", mycell.detailTextLabel.text);

    [self performSegueWithIdentifier:@"Show Site Table" sender:nil];
}

1 个答案:

答案 0 :(得分:0)

听起来你正在寻找表格标题。我认为您无法阅读或以其他方式访问该数据。但您可以使用UITableViewDataSource上的方法设置

-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section

详情如下:

Change UITableView section header/footer WHILE RUNNING the app?

相关问题