我已经在我的应用的iPad迭代中配置了UISplitViewController
,在纵向模式下,有UIBarButtonItem
调出主视图。在横向中,始终显示此视图(主视图和详细视图)。
因为iPad版本对于我的用户来说是新的,并且因为他们习惯在iPhone上看到标签栏,所以我想确保向用户发出菜单消失的警报。
我希望在用户首次启动应用时显示我的主视图。
因此,当用户按下UIBarButtonItem
时,会显示主视图,但是第一次启动应用程序时,我希望显示主视图(即按下UIButton BarButtonItem)。
我很熟悉第一次启动应用时的检查过程。我只需要知道如何调用按钮。
我在详细信息中有这个代码:
#pragma mark - Split View Handler
-(void) turnSplitViewButtonOn: (UIBarButtonItem *)barButtonItem forPopoverController:(UIPopoverController *) popoverController {
barButtonItem.title = NSLocalizedString(@"Master", @"Master");
_splitViewBarButtonItem = barButtonItem;
[self.navigationItem setLeftBarButtonItem:barButtonItem animated:YES];
self.masterPopoverController = (EnvylopeMasterTableViewController *)popoverController;
}
-(void)turnSplitViewButtonOff
{
NSLog(@"SplitViewButtonOff Called");
// Called when the view is shown again in the split view, invalidating the button and popover controller.
[self.navigationItem setLeftBarButtonItem:nil animated:YES];
_splitViewBarButtonItem = nil;
self.masterPopoverController = nil;
}
-(void) setSplitViewButton:(UIBarButtonItem *)splitViewButton forPopoverController:(UIPopoverController *)popoverController
{
NSLog(@"Split View Being Called");
if (splitViewButton != _splitViewBarButtonItem) {
if (splitViewButton) {
NSLog(@"Split View Button Being Called");
[self turnSplitViewButtonOn:splitViewButton forPopoverController:popoverController];
} else {
[self turnSplitViewButtonOff];
NSLog(@"Split View Button Not Being Called");
}
}
}
这是我在Master中的代码:
#pragma mark - Split View Delegate
- (void)splitViewController:(UISplitViewController *)splitController willHideViewController:(UIViewController *)viewController withBarButtonItem:(UIBarButtonItem *)barButtonItem forPopoverController:(UIPopoverController *)popoverController
{
UINavigationController *navController = [[[self splitViewController ] viewControllers ] lastObject ];
id vc = [[navController viewControllers] firstObject];
self.popover = popoverController;
[vc setSplitViewButton:barButtonItem forPopoverController:popoverController];
}
- (void)splitViewController:(UISplitViewController *)splitController willShowViewController:(UIViewController *)viewController invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem
{
UINavigationController *navController = [[[self splitViewController ] viewControllers ] lastObject ];
id vc = [[navController viewControllers] firstObject];
self.popover = nil;
[vc setSplitViewButton:nil forPopoverController:nil];
}
当应用程序启动时,NSLog
“正在调用拆分视图”和“正在调用拆分视图按钮”正在输出到控制台,但是没有按下按钮且主视图不是被显示。
我希望这是有道理的,如果有人对此有任何指导,那将非常感激。