Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

pan17

macrumors newbie
Original poster
Jul 9, 2012
11
0
How to add a barbutton item in the top navigation bar for a popover button in a split view?

Code:
- (void)setSplitViewBarButtonItem:(UIBarButtonItem *)splitViewBarButtonItem
{
    if (_splitViewBarButtonItem != splitViewBarButtonItem) {
        NSMutableArray *items = [self.navBar.leftBarButtonItems mutableCopy];
        if (!items) {
            items = [[NSMutableArray alloc] init];
        }
        if (_splitViewBarButtonItem) [items removeObject:_splitViewBarButtonItem];
        if (splitViewBarButtonItem) [items insertObject:splitViewBarButtonItem atIndex:0];
        self.navBar.leftBarButtonItems = items;
        _splitViewBarButtonItem = splitViewBarButtonItem;
    }
}

This is my protocol for adding the bar button in a navigation item on the top. However, it couldn't show the bar button even i already add it to the self.navBar.leftBarButtonItems.
Then i have to add a new toolbar in that view controller, then it can show the bar button for popover.

Could someone help me out?
Thanks in advance.

----------

I just fix it by adding a new generic view into that top navigation bar item, then add a toolbar for the popover button.

Now it works, finally!

Hope this post might help others who got stuck like i did.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.