将故事板设置为起始文件而不是xib

Ban*_*ore 1 iphone objective-c uiviewcontroller ios uistoryboard

嗨,我有一个基于xib的项目,然后我添加了故事板"main.storyboard".但它仍然运行与初始屏幕替代故事板相同的xib.

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.
Run Code Online (Sandbox Code Playgroud)

以下图片确保我已将故事板作为起始屏幕.

我的旧app app for xib文件,现在我从这里替换xib uiviewcontroller类并把我的新storyboard viewcontroller类名

.h文件

#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
Run Code Online (Sandbox Code Playgroud)

.m文件

#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;
}
Run Code Online (Sandbox Code Playgroud)

yur*_*ish 8

您应该打开Info.plist文件并删除"主nib文件基本名称"键(或键).还要确保"主故事板文件名基础"键包含没有扩展名的故事板的名称.

然后修复main.m文件中的代码.UIApplicationMain用以下行替换呼叫:

UIApplicationMain(argc, argv, nil, NSStringFromClass([AePubReaderAppDelegate class]));
Run Code Online (Sandbox Code Playgroud)