大佬教程收集整理的这篇文章主要介绍了ios – 带有Storyboard的通用应用程序上的UISplitViewController,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
设置如下:
我有一个UITableView(作为主视图),当我选择一行时,它应该显示该单元格的详细视图.我正在使用故事板,我无法弄清楚如何仅为iPad实现拆分视图.
最简单的方法是什么?谢谢.
对于通用应用程序,使用size Classes创建viewcontrollers(通常我们使用任何高度任何宽度的通用应用程序).
根据需要更改这些大小类并为ipad和iphone创建不同的viewcontrollers.在大多数情况下,任何高度任何宽度都可以完成工作.
创建viewcontrollers后,在appdelegate中,使用instantiateViewcontrollerWithIdentifier方法,加载所需的viewcontroller.
if (UI_user_iNTERFACE_I@L_361_12@m() == UIUserInterfaceI@L_361_12@mPad) { // The device is an iPad running ios 3.2 or later. } else { // The device is an iPhone or iPod touch. }
对于ipad加载splitviewcontroller.和iPhone的swrevealviewcontroller.
这是核心基础.如果您需要更多信息,请告诉我.
您是否在故事板中看到了初始VC(viewcontroller)的箭头标记?此vc在启动屏幕后首先加载.在我的应用程序中,我有一个主屏幕,这对于iphone和ipad都是常见的(使用上面提到的大小类因此,我可以将此vc设置为初始VC.在这种情况下,我不需要在appdelegate中执行任何操作.但是如果我有一个不同的ipad主屏幕,那么我可以在appdelegate中进行条件检查didFinishLaunchingWithOptions
您可以像这样加载First屏幕.您应该通过splitVC tutorilal和swrevealcontroller教程来设置侧面菜单.只有在第一个屏幕包含侧边菜单时才应加载SWrevealVC或splitViewcontroller.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { if ([[UIDevice currentDevice] userInterfaceI@L_361_12@m] == UIUserInterfaceI@L_361_12@mPad) { UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; UISplitViewController *split = [storyboard instantiateViewControllerWithIdentifier:@"SplitViewController"]; [AppDelegate setRootController:split storyboard:storyboard actiontype:0]; } else if(UI_user_iNTERFACE_I@L_361_12@m() == UIUserInterfaceIdio@R_580_6165@) { UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; UIViewController *split = [storyboard instantiateViewControllerWithIdentifier:@"SWrevealVC"]; [AppDelegate setRootController:split storyboard:storyboard actiontype:-1]; } return YES; } +(void)setRootController:(UIViewController*)controller storyboard:(UIStoryboard*)storyboard actiontype:(int) actiontype; { if ( UI_user_iNTERFACE_I@L_361_12@m() == UIUserInterfaceI@L_361_12@mPad && actiontype == 0) { UISplitViewController *splitViewController = (UISplitViewController *)controller; //splitViewController.presentsWithGesture = false; UINavigationController *masterNavigationController = [splitViewController.viewControllers objectA@R_197_11520@dex:0]; SideMenuViewController *controller = (SideMenuViewController *)masterNavigationController.topViewController; controller.splitViewController = splitViewController; splitViewController.delegate = (id)controller; } AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; [UIView transitionWithView:appDelegate.window duration:0.5 options:UIViewAnimationOptionAllowAnimatedContent animations:^(void) { BOOL oldState = [UIView areAnimationsEnabled]; [UIView setAnimationsEnabled:NO]; appDelegate.window.rootViewController = controller; [UIView setAnimationsEnabled:oldState]; } completion:nil]; }
代码可能看起来很冗长,但要简单一点.如果你做的话,你只能理解逻辑.
以上是大佬教程为你收集整理的ios – 带有Storyboard的通用应用程序上的UISplitViewController全部内容,希望文章能够帮你解决ios – 带有Storyboard的通用应用程序上的UISplitViewController所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。