在TabBarController中设置SplitviewController的委托

时间:2013-03-27 17:03:07

标签: ios objective-c uitabbarcontroller uisplitviewcontroller

我的项目有一个splitviewcontrollertabbarcontroller作为详情视图,tabbarcontroller上的每个项目都有navigationcontroller

enter image description here

问题是,当我尝试调用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委托方法?

0 个答案:

没有答案