如何切换到iPhone 5的不同Storyboard?
就像一个应用程序为iPad和iPhone使用不同的故事板一样,我希望我的应用程序为iPhone 5使用不同的故事板。由于Info.plist中没有select为iPhone 5select默认故事板的选项,我将如何以编程方式调用故事板?
我不想使用AutoLayout这个应用程序,除非它绝对是最后的手段。 我了解如何检测用户是否正在使用iPhone 5或具有相同屏幕尺寸的其他设备。 我只需要知道如何设置没有plist的默认情节串连图板。
我几周前正在寻找相同的答案这里是我的解决scheme希望帮助..
-(void)initializeStoryBoardBasedOnScreenSize { if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone) { // The iOS device = iPhone or iPod Touch CGSize iOSDeviceScreenSize = [[UIScreen mainScreen] bounds].size; if (iOSDeviceScreenSize.height == 480) { // iPhone 3GS, 4, and 4S and iPod Touch 3rd and 4th generation: 3.5 inch screen (diagonally measured) // Instantiate a new storyboard object using the storyboard file named Storyboard_iPhone35 UIStoryboard *iPhone35Storyboard = [UIStoryboard storyboardWithName:@"Storyboard_iPhone35" bundle:nil]; // Instantiate the initial view controller object from the storyboard UIViewController *initialViewController = [iPhone35Storyboard instantiateInitialViewController]; // Instantiate a UIWindow object and initialize it with the screen size of the iOS device self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; // Set the initial view controller to be the root view controller of the window object self.window.rootViewController = initialViewController; // Set the window object to be the key window and show it [self.window makeKeyAndVisible]; } if (iOSDeviceScreenSize.height == 568) { // iPhone 5 and iPod Touch 5th generation: 4 inch screen (diagonally measured) // Instantiate a new storyboard object using the storyboard file named Storyboard_iPhone4 UIStoryboard *iPhone4Storyboard = [UIStoryboard storyboardWithName:@"Storyboard_iPhone4" bundle:nil]; // Instantiate the initial view controller object from the storyboard UIViewController *initialViewController = [iPhone4Storyboard instantiateInitialViewController]; // Instantiate a UIWindow object and initialize it with the screen size of the iOS device self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; // Set the initial view controller to be the root view controller of the window object self.window.rootViewController = initialViewController; // Set the window object to be the key window and show it [self.window makeKeyAndVisible]; } } else if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) { // The iOS device = iPad UISplitViewController *splitViewController = (UISplitViewController *)self.window.rootViewController; UINavigationController *navigationController = [splitViewController.viewControllers lastObject]; splitViewController.delegate = (id)navigationController.topViewController; } }
在AppDelegate下调用这个方法ddiFinishLaunchingWithOptions:方法也不要忘记你的故事板的名字正确
希望有帮助…
这工作对我来说 – 略微改进与包装获取故事板function
-(UIStoryboard*) getStoryboard { UIStoryboard *storyBoard = nil; if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) { storyBoard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPad" bundle:nil]; }else{ if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone){ // The iOS device = iPhone or iPod Touch CGSize iOSDeviceScreenSize = [[UIScreen mainScreen] bounds].size; if (iOSDeviceScreenSize.height == 480){ // iPhone 3/4x storyBoard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone_4" bundle:nil]; }else if (iOSDeviceScreenSize.height == 568){ // iPhone 5 etc storyBoard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone_5" bundle:nil]; } } } ASSERT(storyBoard); return storyBoard; } UIStoryboard* mainStoryBoard = [self getStoryboard]; self.initialViewController = [mainStoryBoard instantiateInitialViewController]; self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; self.window.rootViewController = self.initialViewController; [self.window makeKeyAndVisible];
- AVAssetWriter输出(UIImage写入video)失真
- Atos无法从存档应用程序的dSYM中获取符号
- MPMediaItemPropertyAssetURL仅为iPhone 5s返回null
- networking链接调节器在OSX Mountain Lion和Xcode 4.4中的预览窗口
- iOS滚动UITableView时展开/select的自定义UITableViewCells状态更改
- 身份validation失败,安装Facebook应用程序(iOS)
- 禁用复制,UITextfield中的粘贴在iOS 9.x中不起作用
- 通过单击表视图中的单元格打开新的视图控制器 – Swift iOS
- 上传到App Store的最低Xcode版本(截至2016年2月)