OC版本:
1.先直接删除SceneDelegate.h/.m文件
2.在AppDelegate.h添加@property (strong, nonatomic) UIWindow * window;属性
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow * window;
@end
3.移除UIScene代理
移除之前
#import "AppDelegate.h"
@interface AppDelegate ()
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
return YES;
}
#pragma mark - 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.
}//移除
@end
移除之后的效果
#import "AppDelegate.h"
@interface AppDelegate ()
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
return YES;
}
@end
4.最后在info.plist文件中移除Application Scene Manifest
Swift版本
1.先直接删除SceneDelegate.swift 文件
2.在AppDelegate.swift 中添加 window 属性 var window: UIWindow?
修改前
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
修改后
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
3.移除UIScene代理
4.最后在info.plist文件中移除Application Scene Manifest
image.png
5.创建自己的Window
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
//设置全局颜色
UITabBar.appearance().tintColor = UIColor.orange
// 创建Window
window = UIWindow(frame: UIScreen.main.bounds)
window?.rootViewController = MainTabViewController();
window?.makeKeyAndVisible()
return true
}
更多方法交流可以家魏鑫:lixiaowu1129,一起探讨iOS相关技术!
网友评论