2014-02-24 61 views
-2

我正在为iPhone创建小应用程序。 是否可以在另一个ViewController中的Cell标题中设置导航栏标题?从单元格标题设置视图控制器标题

谢谢。

+0

u能阐述你的问题? – Marios

+0

将代码添加到您推送viewController的位置,以便我们可以帮助您 –

+0

您可以从应用程序的任何部分设置导航栏标题 –

回答

0

您可以将标题设置为属性,并可在推送时将其设置为didSelectRowAtIndexPath

在viewDidLoad中设置标题。

0

你是否搜索这个电话?

self - >UIViewController

[self setTitle:@"A Title"]; 
1

是的,你可以通过创建一个类的对象做到这一点。你可以设置一个标题。而在此之前,你应该有一个视图控制器

- (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]; 
} 
0

在导航堆栈中新视图控制器创建一个属性,它合成。同时推动,从didSelectRowAtIndexPath传递单元格的值。像这样的:

环顾四周。请参阅此链接Passing Data between View Controllers及其接受的答案。

0
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ 

    UITableCell *cell = [self.tableView cellForRowAtIndexPath:indexPath]; 

    NSString *cellTitle = cell.textLabel.text; 

    detailViewController.title = cellTitle; 

    //navigate; 
} 

希望这有助于你

相关问题