ios app开发学习笔记一
IOS App 窗口结构图
ios13新建的工程,跟ios12有些不同,需要做一些配置才可以走appDelegate。配置方式如下:
- 删除info.plist中Application Scene Manifest选项,同时,文件SceneDelegate可删除可不删除。
- 注释掉AppDelegate.m中的两个方法:
- (UISceneConfiguration *)application:(UIApplication *)application configurationForConnectingSceneSession:(UISceneSession *)connectingSceneSession options:(UISceneConnectionOptions *)options {
return [[UISceneConfiguration alloc] initWithName:@“Default Configuration” sessionRole:connectingSceneSession.role];
} - (void)application:(UIApplication *)application didDiscardSceneSessions:(NSSet<UISceneSession *> *)sceneSessions {
}
工程默认storyboard给我们创建了UIWindow,如果想自己写UIWindow,则需要删除Main.storyboard和Info.plist下面的Main storyboard file base name。在AppDelegate.m中创建UIWindow:
self.window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]];
ViewController *viewController = [[ViewController alloc] init];
self.window.rootViewController = viewController;
[self.window makeKeyAndVisible];
ios13还需要在AppDelegate.h中添加 @property (strong, nonatomic) UIWindow *window;