Iphone 如何在明细视图中显示与表中所选行对应的标题

Iphone 如何在明细视图中显示与表中所选行对应的标题,iphone,objective-c,uitableview,uinavigationcontroller,title,Iphone,Objective C,Uitableview,Uinavigationcontroller,Title,我是iphone开发新手。我正在表中显示一个数据数组。单击该行后,它将导航到相应的详图视图。我想在详图视图中显示与表中所选行对应的标题 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { if([[tableList objectAtIndex:indexPath.row] isEqual:@"Display The Text"]) {

我是iphone开发新手。我正在表中显示一个数据数组。单击该行后,它将导航到相应的详图视图。我想在详图视图中显示与表中所选行对应的标题

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 
    if([[tableList objectAtIndex:indexPath.row] isEqual:@"Display The Text"])
    {  
        secondviewcontroller *second= [[secondviewcontroller alloc] initWithNibName:@"secondviewcontroller" bundle:nil];
        [self.navigationController pushViewController:second animated:YES];
    }

    if([[tableList objectAtIndex:indexPath.row] isEqual:@"iPhone Image"])
    {  
        thirdviewcontroller *third= [[thirdviewcontroller alloc] initWithNibName:@"thirdviewcontroller" bundle:nil];
        [self.navigationController pushViewController:third animated:YES];
    }
}
如果选择了“显示文本”,则相应的导航视图的标题应设置为在导航栏下方“显示文本”作为标题,如果选择了“iphone图像”,则相应的视图应在导航栏下方显示标题“iphone图像”作为标题


请帮帮我,谢谢

在将视图控制器推送到导航堆栈上之前,设置视图控制器的标题。就你而言:

second.title = [tableList objectAtIndex:indexPath.row];

在secondviewcontroller和thirdviewcontroller中声明字符串属性,并添加以下代码。它应该很好用

if([[tableList objectAtIndex:indexPath.row] isEqual:@"Display The Text"])
    {  
        secondviewcontroller *second= [[secondviewcontroller alloc] initWithNibName:                          
                           @"secondviewcontroller" bundle:nil];  
         [self.navigationController pushViewController:second animated:YES];
         second.lblTitle = [tableList objectAtIndex:indexPath.row];
    }


    if([[tableList objectAtIndex:indexPath.row] isEqual:@"iPhone Image"])
    {  
        thirdviewcontroller *third= [[thirdviewcontroller alloc] initWithNibName:@"thirdviewcontroller" bundle:nil];
        [self.navigationController pushViewController:third animated:YES];
         third.lblTitle = [tableList objectAtIndex:indexPath.row];
    }

这将在导航栏中显示标题,但我希望标题显示在导航栏下方(如titleforHeader方法中的标题)。好的,很抱歉我误读了您的问题。在详细视图控制器中声明字符串属性,并在创建控制器时为其指定标题。然后在视图上放置UILabel,并在视图控制器的viewDidLoad中,将该字符串指定为标签文本。我真的不明白这里有什么问题。