我无法通过在详细视图中按左键来显示主视图(即 UITabBarController)。下面的代码是我如何实现 UISplitViewControllerDelegate 来设置左按钮。
我正在使用 iOS 6 和 Xcode 4.5。
#pragma mark - UISplitViewControllerDelegate
#warning "incomplete implementation"
- (BOOL)splitViewController:(UISplitViewController *)svc
shouldHideViewController:(UIViewController *)vc
inOrientation:(UIInterfaceOrientation)orientation {
return UIInterfaceOrientationIsPortrait(orientation) ? YES : NO;
}
- (void)splitViewController:(UISplitViewController *)svc
willHideViewController:(UIViewController *)aViewController
withBarButtonItem:(UIBarButtonItem *)barButtonItem
forPopoverController:(UIPopoverController *)pc {
barButtonItem.title = aViewController.title;
NSMutableArray *toolbarItems = [self.toolbar.items mutableCopy];
[toolbarItems insertObject:barButtonItem atIndex:0];
self.toolbar.items = [toolbarItems copy];
}
- (void)splitViewController:(UISplitViewController *)svc
willShowViewController:(UIViewController *)aViewController
invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem {
NSMutableArray *toolbarItems = [self.toolbar.items mutableCopy];
[toolbarItems removeObject:barButtonItem];
self.toolbar.items = [toolbarItems copy];
}