Split-View应用程序,如何更改popover的标题?

时间:2011-08-23 08:05:55

标签: iphone objective-c uisplitviewcontroller

我有一个拆分视图应用程序。在纵向方向,有一个弹出框,它有一个标题“根视图控制器”,我该如何更改它?而且,当我选择一个单元格时如何跳过弹出窗口?谢谢。这是截图: How to change the Root View Controller title?

2 个答案:

答案 0 :(得分:3)

ViewController集中的

self.navigationItem.title = @"The text you want";

并在选择行时“跳过”弹出窗口,这样做

  - (void)tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
        [self.navigationController dismissModalViewControllerAnimated:YES];

    }

答案 1 :(得分:0)

找到将成为UISplitViewController中主视图的视图控制器,并在viewDidLoad方法中设置标题,如下所示:

self.title = @"Set Title";

由于主视图最终将修改详细视图,因此您可以在详细视图控制器中放置一个方法,以便在选择行后关闭UIPopoverController。以下是一个例子。

所以在DetailViewController(Detail View)中实现这样的方法

    - (void)setDetailDescription:(NSString *)text {

    // Put code to update the detail view here

    [self.popoverController dismissPopoverAnimated:YES];

}

然后在您的RootViewController(主视图)中实现此代码

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

{

DetailViewController *dc = [self.splitViewController.viewControllers objectAtIndex:1];

[dc setDescription:@"Update detail view"];

}

请注意,您的设置会有所不同,因此您必须根据项目调整此代码。