如何手动调用splitview控制器委托方法?

时间:2011-10-08 06:13:19

标签: iphone ios4 uisplitviewcontroller

我在基于Tabbar的应用程序中使用SplitviewController,首先我点击设置(使用Splitviewcontroller)然后调用splitview控制器的委托方法,但是当我点击另一个选项卡后,然后更改方向&然后重新打开设置(使用splitviewcontroller)然后不调用splitviewcontroller的委托方法.......

我知道那个时候只调用viewWillAppear方法,但我想在那时调用splitViewcontroller的委托方法...请告诉我当时如何调用委托方法splitviewController。

提前致谢.....请帮帮我....

主视图控制器中的

- (void)splitViewController:(UISplitViewController*)svc willHideViewController:(UIViewController *)aViewController withBarButtonItem:(UIBarButtonItem*)barButtonItem forPopoverController:(UIPopoverController*)pc {

    // Keep references to the popover controller and the popover button, and tell the detail view controller to show the button.
    barButtonItem.title = @"Settings";
    self.popoverController = pc;
    self.rootPopoverButtonItem = barButtonItem;
UINavigationController *nav = [self.splitViewController.viewControllers objectAtIndex:1];
UIViewController <SubstitutableDetailViewController> *detailViewController = [nav.viewControllers objectAtIndex:0];
    [detailViewController showRootPopoverButtonItem:rootPopoverButtonItem]; 
}

- (void)splitViewController:(UISplitViewController*)svc willShowViewController:(UIViewController *)aViewController invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem {

UINavigationController *nav = [self.splitViewController.viewControllers objectAtIndex:1];
    UIViewController <SubstitutableDetailViewController> *detailViewController = [nav.viewControllers objectAtIndex:0];
    [detailViewController invalidateRootPopoverButtonItem:rootPopoverButtonItem];
    self.popoverController = nil;
    self.rootPopoverButtonItem = nil;
}

详细视图

- (void)showRootPopoverButtonItem:(UIBarButtonItem *)barButtonItem {
// Add the popover button to the left navigation item.
[self.navigationController.navigationBar.topItem setLeftBarButtonItem:barButtonItem animated:NO];
}

- (void)invalidateRootPopoverButtonItem:(UIBarButtonItem *)barButtonItem {
// Remove the popover button.
[self.navigationController.navigationBar.topItem setLeftBarButtonItem:nil animated:NO];
}

0 个答案:

没有答案