在分割视图控制器中选择主视图的选项卡时更改详细视图。

问题描述 投票:1回答:2

我是ipad开发的新手。在我的应用程序中,我创建了如下图所示的splitview。在此,当左窗格上的tabbar选择变化时,我如何调用另一个详细视图控制器?

请帮助我...

My Splitview Screen

iphone objective-c ios ipad uisplitviewcontroller
2个回答
1
投票

你可以简单地替换UISplitViewController的viewControllers属性索引1的VC。试试类似的东西

- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
{
     UIViewController* myReplacementVC = nil;
      if(viewController == VC1)
           myReplacementVC = myReplacementVC1;
      else
           myReplacementVC = myReplacementVC2; 

      NSMutableArray* arr = [[NSMutableArray alloc] initWithArray:splitVC.viewControllers];
          [arr replaceObjectAtIndex:1 withObject:myReplacementVC]; //index 1 corresponds to the detail VC
          splitVC.viewControllers = arr;
          [arr release];
    }

© www.soinside.com 2019 - 2024. All rights reserved.