uitableview +导航控制器从所选元素中设置标题

obi*_*ter 2 xcode objective-c uitableview uinavigationcontroller ios

我有一个UINnavigationController处理导航的UITableView.

当我从表格中选择一行时,我需要在UINavigationController标题中显示上一个菜单中的所选项目.

xml填充行的外部读取单元格的标签UITableView.

如何在标题上显示我的选择UINavigationBar

我使用self.title命令设置了静态标题,但它不符合我的需要

Flu*_*imp 5

这对您有用吗?

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;
{
    DetailTableViewController *detailController = [[DetailTableViewController alloc] initWithStyle:UITableViewStyleGrouped];
    //   Set the detail controller title to whatever you want here...
    detailController.title = @"Your title";

    //   Or set it to the title of this row
    UITableViewCell *cell = [[self tableView] cellForRowAtIndexPath:indexPath];
    detailController.title = cell.textLabel.text;

    [[self navigationController] pushViewController:detailController animated:YES];
}
Run Code Online (Sandbox Code Playgroud)


Ale*_*Cio 5

Normaly的UINavigationController总是挑选出title了的UIViewController已实际加载.这就是为什么你必须在里面定义它viewDidLoad:

self.title = @"Title";
Run Code Online (Sandbox Code Playgroud)

上面显示的方法似乎更具动态......但这也有效.