Could not find a storyboard named 'Main' in bundle NSBundle ios 新建项目删除Main.storyboard报错
废话少说 直接流程
1. 删除Main.storyboard
2. iOS13引入了分屏,在SceneDelegate.m中添加代码
如果项目不使用分屏也按这个步骤继续往下走
- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions {
if (scene) {
UIWindowScene *windowScene = (UIWindowScene *)scene;
self.window = [[UIWindow alloc]initWithWindowScene:windowScene];
ViewController *vc =[[ViewController alloc]init];
vc.view.backgroundColor = [UIColor whiteColor];//如果不设置背景颜色,屏幕一会就会自动变黑,有知道原因的请赐教
self.window.rootViewController = vc;
[self.window makeKeyAndVisible];
}
}
3. 删除info.plist下的Storyboard Name
4. 删除TARGETS下Deployment info下的Main interface的main
5. clear工程 重新运行
这样就可以了。如果项目没有分屏不用SceneDelegate,那就继续往下步骤走
5. AppDelegate更改
AppDelegate.h添加window属性
@property (strong, nonatomic) UIWindow * window;
AppDelegate.m添加如下代码
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
ViewController *vc =[[ViewController alloc]init];
vc.view.backgroundColor = [UIColor whiteColor];
self.window.rootViewController = vc;
[self.window makeKeyAndVisible];
return YES;
}
同时删除下面的UISceneSession lifecycle方法
- (UISceneConfiguration *)application:(UIApplication *)application configurationForConnectingSceneSession:(UISceneSession *)connectingSceneSession options:(UISceneConnectionOptions *)options {
// Called when a new scene session is being created.
// Use this method to select a configuration to create the new scene with.
**return** [[UISceneConfiguration alloc] initWithName:@"Default Configuration" sessionRole:connectingSceneSession.role];
}
- (**void**)application:(UIApplication *)application didDiscardSceneSessions:(NSSet<UISceneSession *> *)sceneSessions {
// Called when the user discards a scene session.
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}
6. 删除SceneDelegate.h和SceneDelegate.m
7. 删除info.plist下的Application Scene Manifest
8. 删除TARGETS下info的Application Scene Manifest
clean一下 就可以了。