我的项目有一个splitviewcontroller
,tabbarcontroller
作为详情视图,tabbarcontroller上的每个项目都有navigationcontroller
问题是,当我尝试调用splitview控制器委托方法时,例如当应用程序转到纵向时,在左侧栏按钮项上放置一个popovercontroller按钮,一次只有一个viewcontroller可以执行此操作。
让我说我在每个控制器中调用跟随只有第一个视图控制器加载到屏幕使用按钮其他viewcontroller在tabbarcontroller中不能调用splitviewcontroller委托。
#pragma mark - Split view
- (void)splitViewController:(UISplitViewController *)splitController willHideViewController:(UIViewController *)viewController withBarButtonItem:(UIBarButtonItem *)barButtonItem forPopoverController:(UIPopoverController *)popoverController
{
barButtonItem.title = NSLocalizedString(@"Master", @"Master");
[self.navigationItem setLeftBarButtonItem:barButtonItem animated:YES];
self.masterPopoverController = popoverController;
}
- (void)splitViewController:(UISplitViewController *)splitController willShowViewController:(UIViewController *)viewController invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem
{
// Called when the view is shown again in the split view, invalidating the button and popover controller.
[self.navigationItem setLeftBarButtonItem:nil animated:YES];
self.masterPopoverController = nil;
}
- (void) awakeFromNib{
[super awakeFromNib];
self.splitViewController.delegate = self;
}
当我尝试按照设置委托并且为零时,有时候工作有时没有。
-(void)viewWillAppear:(BOOL)animated{
self.splitViewController.delegate=self;
}
-(void)viewWillDisappear:(BOOL)animated
{
self.splitViewController.delegate=nil;
}
如何在每个tabbarcontroller项(viewcontrollers)上调用splitviewcontroller委托方法?