美文网首页
SceneDelegate带来的问题 2022-04-08 周五

SceneDelegate带来的问题 2022-04-08 周五

作者: 勇往直前888 | 来源:发表于2022-04-08 19:46 被阅读0次

切换主storyboard

  • 本来只要在工程设置切换一下就好了。比如下面这样
原来切换很简单
  • 现在要手动修改info.plist中的配置项才能起效果
    路径: info -> Application Scene Manifest -> Scene Configuration -> Application Session Role -> item 0 -> Storyboard Name
手动改

xcode11新项目删除main.storyboard 两种方法

IOS 使用Xcode11新建项目scenedelegate处理和Main.storyboard的处理

代码写界面

  • 本来会在AppDelegate的方法中写
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. return YES; }

  • 现在要改到SceneDelegate的方法中写
    - (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions

Xcode13纯代码

全局的Windows不可用

问题:

[UIApplication sharedApplication].delegate.window是常用的一个属性,很多第三方库比如SVProcessHUD都在用,可是现在不能用了。

解决方法:

  1. AppDelegate中添加window属性
@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (nonatomic, strong) UIWindow *window;

@end
  1. SceneDelegate中设置window属性
- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions {
    // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
    // If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
    // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
    
    [UIApplication sharedApplication].delegate.window = self.window;
}

-[AppDelegate window]: unrecognized selector sent to instance

相关文章

网友评论

      本文标题:SceneDelegate带来的问题 2022-04-08 周五

      本文链接:https://www.haomeiwen.com/subject/onnysrtx.html