Ios 基于方向以编程方式更改拆分视图
我意识到Apple文档建议将拆分视图设置为根视图控制器。所以本质上我有一个带有标签栏的应用程序。在选项卡栏的第一个索引内,我有一个拆分视图。当设备的方向为纵向时,我希望(分割的主细节)填充整个屏幕或成为详细页面,但更重要的是,当设备为纵向时,我没有选择具有主细节。因此,我的想法是根据设备的方向交换选项卡栏索引。我的代码是这样的:Ios 基于方向以编程方式更改拆分视图,ios,objective-c,uisplitviewcontroller,Ios,Objective C,Uisplitviewcontroller,我意识到Apple文档建议将拆分视图设置为根视图控制器。所以本质上我有一个带有标签栏的应用程序。在选项卡栏的第一个索引内,我有一个拆分视图。当设备的方向为纵向时,我希望(分割的主细节)填充整个屏幕或成为详细页面,但更重要的是,当设备为纵向时,我没有选择具有主细节。因此,我的想法是根据设备的方向交换选项卡栏索引。我的代码是这样的: -(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientati
-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{
if( UIInterfaceOrientationIsLandscape(toInterfaceOrientation) )
{
UISplitViewController * splitview = [[UISplitViewController alloc]init];
//
// splitview.delegate =self;
// [splitview willRotateToInterfaceOrientation:self.interfaceOrientation duration:0];
NSLog(@"LandScape!!");
NSMutableArray * array = [MyCustomwViewManager changeHomeOrientationTolandScape:[NSMutableArray arrayWithArray:self.tabBarController.viewControllers] viewController:self navigationController:self.navigationController splitView:splitview];
[self.tabBarController setViewControllers:array animated:YES];
// [self viewDidLoad];
} else {
NSMutableArray * changeSplit = [NSMutableArray arrayWithArray: self.splitViewController.viewControllers];
NSMutableArray * array = [MyCustomViewManager changeHomeOrientationToPortrait:[NSMutableArray arrayWithArray:self.tabBarController.viewControllers] viewController:[changeSplit objectAtIndex:0] navigation:[changeSplit objectAtIndex:0]];
[self.tabBarController setViewControllers:array animated:YES];
}
}
我的目标是实现类似于yelp iPad应用程序的功能。希望我是清楚和有意义的