Bangalore
Bangalore

Reputation: 1580

Set storyboard as starting file instead of xib

Hi i have a xib based project then i have added a storyboard "main.storyboard". But it still running the same xib as initial screen stead of storyboard.

2013-12-18 16:44:14.376 AePubReader[1882:60b] NSMainNibFile and UIMainStoryboardFile are both set. NSMainNibFile ignored.
2013-12-18 16:44:14.396 AePubReader[1882:60b] There is no app delegate set. An app delegate class must be specified to use a main storyboard file.

the following images are make sure that i have given storyboard as starting screen.

my old app delegate for xib file ,now i replace xib uiviewcontroller class from here and put my new storyboard viewcontroller class name

.h file

#import <UIKit/UIKit.h>


@class viewViewController;

@interface AePubReaderAppDelegate : NSObject <UIApplicationDelegate> {

    UIWindow *window;

    viewViewController *detailViewController;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;

@property (nonatomic, retain) IBOutlet viewViewController *detailViewController;

@end

.m file

#import "AePubReaderAppDelegate.h"


#import "ViewController.h"


@implementation AePubReaderAppDelegate

@synthesize window, detailViewController;


#pragma mark -
#pragma mark Application lifecycle

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

//    // Override point for customization after app launch.
//    
//   self.window.rootViewController = self.detailViewController;
// [self.window makeKeyAndVisible];
//    
//   // [detailViewController loadEpub:@"ker"];

    return YES;
}

Upvotes: 1

Views: 3811

Answers (3)

user3115014
user3115014

Reputation: 697

Under your application didFinishLaunchingWithOptions: in the appdelegate insert this code:

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Your Soryboard name"  bundle:nil];

// Instantiate the initial view controller object from the storyboard
initialViewController = [storyboard instantiateInitialViewController];

Upvotes: 0

yurish
yurish

Reputation: 1535

You should open the Info.plist file and delete the "Main nib file base name" key (or keys). Also make sure that "Main storyboard file name base" key contains the name of your storyboard without extension.

Then fix code in you main.m file. Replace UIApplicationMain call with following line:

UIApplicationMain(argc, argv, nil, NSStringFromClass([AePubReaderAppDelegate class]));

Upvotes: 8

Andy Kaminski
Andy Kaminski

Reputation: 142

You missed a bit. Try:

UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"main.storyboard" bundle:nil];
UIViewController *initViewController = [storyBoard instantiateInitialViewController];
[self.window setRootViewController:initViewController];

Upvotes: 0

Related Questions