Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories

Xcode 6 using multiple storyboards

I figured out an answer myself. The code is slightly different but it works very well. As said above by Matt, it's important to put NSLogs in your code so you know what is running and what is not. The first thing is I was using this code for a landscape app. There is a simple fix for this. You have to change the word Height to Width. The other thing is this will not work for the iPhone 6 or 6 plus if you do not have a launch image file. Not just a regular xcasset you also have to have a xib as a launch image which was added in Xcode 6. The code is below, please just note that in the #define it says height, if you are using this in a LANDSCAPE app change hight to width.

... This goes right under where it says "#import AppDelegate.h"

#define IS_IPHONE_4
mainScreen]bounds].size.height - (double)480) <
#define IS_IPHONE_5 (fabs((double)[[UIScreen
mainScreen]bounds].size.height - (double)568) <
#define IS_IPHONE_6 (fabs((double)[[UIScreen
mainScreen]bounds].size.height - (double)667) <
#define IS_IPHONE_6_PLUS (fabs((double)[[UIScreen
mainScreen]bounds].size.height - (double)736) <

... This goes in your "view did finish launching with options"

self.window = [[UIWindow alloc]
initWithFrame:[[UIScreen mainScreen] bounds]];

if (IS_IPHONE_4) {
    UIStoryboard *storyboard = [UIStoryboard
bundle:[NSBundle mainBundle]];
    UIViewController *vc =[storyboard
    self.window.rootViewController = vc;
    NSLog(@"iPhone 4 storyboard loaded up.");
else if(IS_IPHONE_6) {
    UIStoryboard *storyboard1 = [UIStoryboard
bundle:[NSBundle mainBundle]];
    UIViewController *vc1 =[storyboard1
    self.window.rootViewController = vc1;
    NSLog(@"iPhone 6 storyboard loaded up.");
else if(IS_IPHONE_5) {
    UIStoryboard *storyboard1 = [UIStoryboard
bundle:[NSBundle mainBundle]];
    UIViewController *vc2 =[storyboard1
    self.window.rootViewController = vc2;
    NSLog(@"iPhone 5 storyboard loaded up.");

[self.window makeKeyAndVisible];

...If you are using a landscape app, you will not be able to rotate the screen from landscape left to landscape right and vice versa.

If you want to be able to do that you can REMOVE this line... self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

If your code does not work correctly after removing that, put it back in and just don't have it rotate.

That code works and if you have any problems with it leave a comment. There is no need to delete anything from your plist or general page.

Also if you want to add a six plus line, just copy and paste one of the other if statements and change it to #define IS_IPHONE_6_PLUS. Just make sure you change it from vc1 2 or just vc to vc3 in both spots.

Categories : IOS

Related to : Xcode 6 using multiple storyboards
Using multiple Storyboards in Xcode
Find your info.plist file in your project and remove the line called "Main storyboard file base name". Also, you forgot to create the window (credits to rdelmar). self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; I strongly advise you to look into Auto Layout and Size Classes. Using these two, you can support all screen sizes within one single Storyboard. It's a bit

Categories : IOS
Xcode choose storyboards at launch (Xcode 6)
you can have these conditions, one for iPhone 4,4s (960) and the other for 5,5s,6,6plus (1136) the last for ipads if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone){ UIStoryboard *storyBoard; CGSize result = [[UIScreen mainScreen] bounds].size; CGFloat scale = [UIScreen mainScreen].scale; result = CGSizeMake(result.width * scale, result.height * scale)

Categories : IOS
Xcode 6: Storyboards
You could try loading the storyboard in your AppDelegate. Described here: Create 2 storyboards and then just load the preferred one in your AppDelegate.

Categories : IOS
Creating Storyboards Xcode 6
You definitely want to be doing File>New and going to User Interface and creating an empty storyboard from the selection. I've done this but make sure to tell Xcode that you want one storyboard for the iPad and another for the iPhone. Your code is to access an already existing storyboard file in the main bundle.

Categories : IOS
How should you set up an Xcode project that uses storyboards and allows View Controllers to be tested in isolation (and allow rapid iteration)?
For quick iterations, I like to make an Xcode sub-project. To this by selecting the project file (the blue one), and then doing File->New... project. In the save window, select "Add to" to place it inside your project. Then, just add your existing files by reference (make sure not to copy them!). They will build and run independently of the rest of the larger project. This is especially usefu

Categories : IOS
Recently Add
why scrollView.frame = CGRectMake() not work
Codesigning failed when building app from terminal
View presented by UINavigationController embedded in UITabBarController doesn't size view to account for tabBar at bottom of view
App Groups and iCloud in iOS
What is the purpose of the init! failable initializer?
Trying to segue to another view controller using an alert action, in Swift
ios - Action from UITableView to a UIViewController
Unused variable warning in XCode 6
What happens when you touch two buttons at the same time
Adding pan gesture to multiple dynamically created views?
Edit UI Table View, Call Between Swipe And Button Display
Detect whether device can receive sms
NSPredicate for array of Dictionaries generating null array
Send iOS push notifications to multiple devices
Send IPad App for review every x days ( continuous deploy )
Constraints are working on iOS 8, but not on iOS 7 Friend Relations
Sorting NSMutableArray with custom class by date
How to programmatically slice an image in 4 , 9 , 16 and 25 slices
Redraw issue with UITableView using Objective C and Xcode 6
How to convert string "$double_number" to double number
Switching from iBeacon to BLE in real time?
Weekly subscription payment in inapp purchase
What's the advantages of using NSOutputstream?
CoreData Issue: There was an error creating or loading the application's saved data
Update UITableView size based on UIView constraints
Run code in background
How to deploy app in ios simulator(Xcode 6.0.1)
Cannot get permission for user_events facebook
Unexplainable memory leak swift iOS
© Copyright 2017 Publishing Limited. All rights reserved.