问题
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