1.新建項目
2.解決ios13以下運行閃退問題
1)刪除SceneDelegate.swift
官方文檔:
In iOS 13 and later, use UISceneDelegate objects to respond to life-cycle events in a scene-
based app.
這個場景呢,如果不使用ipad的多窗口就不建議使用
2)刪除 Main.storyboard,不使用storyboard佈局,打開info.plist,刪除Main storyboard file base name和Application Scene Manifest選項。
3)刪除appdelegate 中關於scene的2個代理
4)appdelegate中添加根導航
//swift
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
let screen = UIScreen.main.bounds //獲得設備尺寸
self.window = UIWindow.init(frame: screen) //給“輸出窗口“實例化並設置frame
let viewController = ViewController() //實例化一個ViewController
let navigationController = UINavigationController(rootViewController: viewController) //爲ViewController設置一個導航欄
self.window?.rootViewController = navigationController//將“輸出窗口”的根視圖設置爲導航欄
self.window?.makeKeyAndVisible() // 設置"輸出窗口可見"
return true
}
}
//OC
@interface AppDelegate ()<UISplitViewControllerDelegate>
@property (strong, nonatomic) UIWindow *window;
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc]init];
self.window.frame = [UIScreen mainScreen].bounds;
LogInViewController *loginVC = [[LogInViewController alloc]initWithNibName:@"LogInViewController" bundle:nil];
self.window.rootViewController = loginVC;
[self.window makeKeyAndVisible];
return YES;
}