UISplitViewController : how to present master view in the detail view by button event instead of via a swipe gesture

ⅰ亾dé卋堺 提交于 2019-12-11 10:15:53

问题


Swipe gesture is cool to present master view in portrait orientation. But I want to know how to present the table by button event instead of via a swipe gesture. I do not want to present popover, I like the slide animation. Any comments will be appreciated.


回答1:


For future reference, by setting the split view controller delegate and implementing this two methods you should be ready to go.

- (void)splitViewController:(UISplitViewController *)svc willShowViewController:(UIViewController *)aViewController invalidatingBarButtonItem:(UIBarButtonItem *)button
    {
        //remove button from navigation bar in detail navigation controller
        ((UINavigationController*)[svc.viewControllers objectAtIndex:1]).topViewController.navigationItem.leftBarButtonItem = nil;
    }

- (void)splitViewController: (UISplitViewController*)svc willHideViewController:(UIViewController *)aViewController withBarButtonItem:(UIBarButtonItem*)barButtonItem forPopoverController: (UIPopoverController*)pc{

        //add button to navigation bar in detail navigation controller
        barButtonItem.title = @"Navigation";
        ((UINavigationController*)[svc.viewControllers objectAtIndex:1]).topViewController.navigationItem.leftBarButtonItem = barButtonItem;

    }

The instance of barButtonItem handles all the toggle process for you.



来源:https://stackoverflow.com/questions/14334939/uisplitviewcontroller-how-to-present-master-view-in-the-detail-view-by-button

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!