Search code examples
uisplitviewcontrolleripad

setting the title of a barButtonItem in the detailView of a splitViewController


I am a newbie at iOS and an struggling with something related to with a split view controller.

I have a split view controller where the master is a navigationController, containing a tabBarController. The tabBarController has two tabs, each pointing to TableViewControllers in it's own navigationControllers.The detail view of the splitView is the splitViewDelegate.

The part where I am struggling is in the splitViewController-willHideViewController-withBarButtonItem-forPopoverController.

I want to set the title of the barButtomItem based on the title displayed in the master.

I would appreciate if anyone can help me figure this and maybe understand the missing pieces in the process.

thanks


Solution

  • Here is the code used to access the title of the master using the default split view controller project:

    UINavigationController *nav  = [[self.splitViewController viewControllers] objectAtIndex:0];
    MasterViewController *master = (MasterViewController *)[nav topViewController];
    barButtonItem.title          = master.title;