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

2022-04-08  本文已影响0人  勇往直前888

切换主storyboard

原来切换很简单 手动改

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

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

代码写界面

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

上一篇 下一篇

猜你喜欢

热点阅读