在 iOS 26 之后,通过 UIScene 的 open(_:options:completionHandler:) 方法,可以非常方便地实现这一功能。 前提 文件位于可访问的共享沙盒目录。
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions UIWindowScene) else { return } } func sceneWillEnterForeground(_ scene: UIScene) { // 隐藏 hidePrivacyWindow() } func sceneDidEnterBackground(_ scene: UIScene) { // 显示
configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions LoginViewController.h" @interface SceneDelegate() @end @implementation SceneDelegate -(void)scene:(UIScene self.window]; } @end 上篇文章我们分析到UIWindow的继承关系发生了变化需要通过Scene来进行初化,而Scene变化为称为Respender的子类可以响应事件而不再是之前那个单纯的UIScene func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions (_ scene: UIScene) { } func sceneWillResignActive(_ scene: UIScene) { } func sceneWillEnterForeground (_ scene: UIScene) { } func sceneDidEnterBackground(_ scene: UIScene) { } } scene(_:willConnectTo func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions
完成启动后,控制权被交接给 SceneDelegate,它的 scene(_:willConnectTo:options:)将会被调用,设置window的根视图控制器 func scene(_ scene: UIScene , willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions UIWindowScene) else { return } } func sceneWillEnterForeground(_ scene: UIScene) { / / 隐藏 hidePrivacyWindow() } func sceneDidEnterBackground(_ scene: UIScene) {
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions UIWindowScene) else { return } } func sceneDidDisconnect(_ scene: UIScene) { } func sceneDidBecomeActive(_ scene: UIScene) { } func sceneWillResignActive(_ scene: UIScene) { } func sceneWillEnterForeground(_ scene: UIScene) { } func sceneDidEnterBackground(_ scene : UIScene) { } } 初始化 Main Storyboard 解析 Info.plist 获得Application Scene Manifest,找到Main Storyboard
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions UIWindowScene) else { return } } func sceneDidDisconnect(_ scene: UIScene) { // Called as paused (or not yet started) when the scene was inactive. } func sceneWillResignActive(_ scene: UIScene temporary interruptions (ex. an incoming phone call). } func sceneWillEnterForeground(_ scene: UIScene to undo the changes made on entering the background. } func sceneDidEnterBackground(_ scene: UIScene
viewController.navigationController setNeedsUpdateOfSupportedInterfaceOrientations]; // find scene NSArray<UIScene *> *scenes = [[[UIApplication sharedApplication] connectedScenes] allObjects]; __block UIScene *firstScene = scenes.firstObject; [scenes enumerateObjectsUsingBlock:^(UIScene * _Nonnull obj
static变量,从而我们可以臆断这个就是渲染的主要地方和实现 接下来我们看看怎么在开发中使用 在使用之前我们会发现多了个类 SceneDelegate func scene(_ scene: UIScene , willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions
func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) { if let url = URL func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) { if let url = URLContexts.first
func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) { if let url = URL func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) { if let url = URLContexts.first
application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 转交给SceneDelegate.m: - (void)scene:(UIScene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions - (void)scene:(UIScene
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { guard let windowScene = (scene as?
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { guard let windowScene = (scene as?
SceneDelegate.h/.m文件 2.在AppDelegate.h添加@property (strong, nonatomic) UIWindow * window;属性 3.在AppDelegate.m文件中移除UIScene
所有 App 必须使用 UIScene 生命周期,不再允许只使用 AppDelegate。 UIKit 支持显示 HDR(高动态范围)颜色 ,而不仅仅是 HDR 图像。 通过改进的 UIScene 的open()方法,可以将不受支持的类型文件交给其他 App 打开。
所有 App 必须使用 UIScene 生命周期,不再允许只使用 AppDelegate。 UIKit 支持显示 HDR(高动态范围)颜色 ,而不仅仅是 HDR 图像。 通过改进的 UIScene 的open()方法,可以将不受支持的类型文件交给其他 App 打开。 注:以上内容基于 Xcode 26 Beta,新特性均通过测试,详细内容会以专题文章的形式陆续展示。
bin文件的分享列表里看到自己的app了,如图: 第二步:获取文件 当从其他app分享文件过来时,会调用: // MARK: - 其他app分享过来时回调 func scene(_ scene: UIScene
并且分别创建Main ViewController View Model 截屏2021-09-24 下午2.12.56.png 三·实现Screen的Delegate方法 - (void)scene:(UIScene