iOS MainStoryBoard 在实际开发过程中,使用场景并不多,(做做demo除外),但删除它的次数也不多,给CV战士提供一套快捷入口
准备 Xcode工程 OC去除ManStoryBoard1,删除Main.storyboard文件
2,工程-> TARGETS -> Info.plist中 删除Main storyboard file base name
3,工程AppDelegate.m改造
//
// AppDelegate.m
// JDTVideoPlayer
//
// Created by yuezhimin on 07/15/2020.
// Copyright (c) 2020 JDT. All rights reserved.
//
#import "AppDelegate.h"
// 引入主控制器
#import "ViewController.h"
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
ViewController *viewController = [[ViewController alloc] init];
//如果不需要NavigationController时,直接 self.window.rootViewController = viewController; UITabBarController一样逻辑
UINavigationController *nVC = [[UINavigationController alloc] initWithRootViewController:viewController];
self.window.rootViewController = nVC;
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
@end
Swift去除ManStoryBoard
1,删除Main.storyboard文件
2,工程-> TARGETS -> Info.plist中 删除Main storyboard file base name
3,工程AppDelegate.swift改造
//
// AppDelegate.swift
// CreateAppTest
//
// Created by yuezhimin on 2020/10/28.
//
import UIKit
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
self.window = UIWindow(frame: UIScreen.main.bounds)
let vc = ViewController()
let navVC = UINavigationController(rootViewController: vc)
self.window?.rootViewController = navVC
self.window?.backgroundColor = .white
self.window?.makeKeyAndVisible()
return true
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)