iOS object-c和Swift移除SceneDelegate

OC環(huán)境下:

1.先直接刪除SceneDelegate.h/.m文件

2.在AppDelegate.h添加@property (strong, nonatomic) UIWindow * window;屬性

#import

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow * window;

@end

3.移除UIScene代理

移除之前


#import "AppDelegate.h"

@interface AppDelegate ()

@end

@implementation AppDelegate

- (BOOL)application:(UIApplication*)applicationdidFinishLaunchingWithOptions:(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*)applicationdidDiscardSceneSessions:(NSSet *)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*)applicationdidFinishLaunchingWithOptions:(NSDictionary*)launchOptions {

? ? // Override point for customization after application launch.

? ? return YES;

}

@end

4.最后在info.plist文件中移除Application Scene Manifest

Swift環(huán)境下也是一樣的:

1.先直接刪除SceneDelegate.swift文件

2.在info.plist文件中刪除Application scene manifest

3.刪除AppDelegate中的兩個(gè)方法

4.在Appdelegate中增加window屬性


知識(shí)補(bǔ)充:SceneDelegate

Xcode 11 建新工程默認(rèn)會(huì)創(chuàng)建通過(guò) UIScene 管理多個(gè) UIWindow 的應(yīng)用,工程中除了 AppDelegate 外還會(huì)有一個(gè) SceneDelegate,這是為了實(shí)現(xiàn)iPadOS支持多窗口的結(jié)果。如果僅開發(fā)iPhone應(yīng)用而非iPad,那么該文件可放心地刪除。

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容