开发者

Split-View application, how to change header for popover?

开发者 https://www.devze.com 2023-03-29 20:12 出处:网络
I\'ve got a split-view application. When in Portrait orientation, there is a popover, it has a title \"Root View Controller\", how can I change it? moreover, how to skip 开发者_如何学Pythonpopover whe

I've got a split-view application. When in Portrait orientation, there is a popover, it has a title "Root View Controller", how can I change it? moreover, how to skip 开发者_如何学Pythonpopover when I select a cell? thanks. Here is the screenshot:

Split-View application, how to change header for popover?


in the ViewController set

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

and to "skip" the popover when a row is selected do sometime like this

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

    }


Find the view controller that will be the master view in the UISplitViewController and set the title in the viewDidLoad method like this:

self.title = @"Set Title";

Since the master view will eventually modify the detail view you can place a method in the detail view controller to dismiss the UIPopoverController after you select a row. Below is an example.

So in DetailViewController(Detail View) implement a method like this

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

    // Put code to update the detail view here

    [self.popoverController dismissPopoverAnimated:YES];

}

And then in your RootViewController(Master View) implement this code

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

{

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

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

}

Take note that your setup will vary so you will have to adapt this code to your project.

0

精彩评论

暂无评论...
验证码 换一张
取 消