- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
在我的 SwiftUI 项目中,我看到了 AppDelegate
文件以及一个 SceneDelegate
文件。
它们之间有什么区别?
例如SceneDelegate
中的方法之间
scene(_:willConnectTo:options:)
并且在 AppDelegate
application(_:didFinishLaunchingWithOptions:)
最佳答案
这两个文件旨在根据运行整个应用程序所需的工作以及支持在后台明显运行的一个“实例”所需的工作来划分工作。这类似于一次配置数据库,但通过窗口显示不同的值集。
您可以将它们视为全局版本和私有(private)版本。一个是共享的,另一个仅限于个人所有者。在某种程度上,它们正是您所期望的名称。
Multi-window support is happening
Next time you create a new Xcode project you’ll see your AppDelegate has split in two: AppDelegate.swift and SceneDelegate.swift. This is a result of the new multi-window support that landed with iPadOS, and effectively splits the work of the app delegate in two.
From iOS 13 onwards, your app delegate should:
- Set up any data that you need for the duration of the app.
- Respond to any events that focus on the app, such as a file being shared with you.
- Register for external services, such as push notifications.
- Configure your initial scenes.
In contrast, scene delegates are there to handle one instance of your app’s user interface. So, if the user has created two windows showing your app, you have two scenes, both backed by the same app delegate.
Keep in mind that these scenes are designed to work independently from each other. So, your application no longer moves to the background, but instead individual scenes do – the user might move one to the background while keeping another open.
由 https://www.hackingwithswift.com/articles/193/whats-new-in-ios-13 提供
关于swift - SceneDelegate 和 AppDelegate 的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56498099/
我来自 react-native 和 Swift 和 SwiftUI 的初学者,我很好奇当应用程序回到前台时如何在特定屏幕上执行操作和更新状态。我想检查通知的状态(“允许”、“拒绝”等)并更新 UI。
在 SceneDelegate.swift 中,以下代码返回错误消息 “使用未解析的标识符‘ContentView’;你是说‘ContentMode’吗?”。 func scene(_ scene:
我正在尝试从 SceneDelegate 中恢复模态 Viewcontroller。 然而,此代码不允许模态视图 Controller 显示并导致以下错误: “对...的开始/结束外观转换的调用不平衡
在我的 SwiftUI 项目中,我看到了 AppDelegate 文件以及一个 SceneDelegate 文件。 它们之间有什么区别? 例如SceneDelegate中的方法之间 scene(_:w
我有一个 music flutter 应用程序,现在我正在快速实现 native 播放器代码,该应用程序与 spotify ios sdk 集成。 我正在尝试运行,但 Spotify 连接功能在 IO
我想使用 SwfitUI 在 macOS 上制作一些应用程序。 继iOS之后,还有SceneDelegate (在 iOS 13 之后)。但是在 macOS 中,只有 AppDelegate . 好的
在 iOS 13 中,使用 UIScene。 AppDelegate.cs 中的代码必须移动到 SceneDelegate.cs 中才能在拆分 View 中支持同一应用程序的多个窗口。 对于 Xama
通过停靠图标退出催化剂应用程序时(右键单击 -> 退出),我的 SceneDelegate 的 stateRestorationActivity(for scene: UIScene) 方法被调用,并
我这里有一个模型: class Instance: ObservableObject { @Published var status: Status = .offline 它会在更改时更新以下
在 iOS 13 之前,导航 Controller 和 Root View 是在 AppDelegate 中定义的。然而,在 iOS 13 中,Apple 引入了 SceneDelegate,它接管了
我正在尝试了解如何从 Swift 函数代码加载 SwiftUI View 。在这个具体情况,我想在从后台状态返回到覆盖敏感数据。我已经创建了一个生物识别登录并且工作正常 - 纯应用程序的 SwiftU
所以我是 Swift 的新手。我认为这是一种快速发展的语言。 但是我看到的很多教程都将 AppDelegate 和 SceneDelegate 作为标准 init 文件,为什么我没有呢?为什么我似乎找
我在我的 SceneDelegate 中定义了一个 let 属性。我希望某些 ViewController 能够在场景中访问它。 在 UIKit 中,我可以像这样访问 App Delegate 属性:
当 iOS 13 发布时,我选择不通过正常程序使用新的 SceneDelegate。 - SceneDelegate.swift does no longer exist - There are
在我的 SceneDelegate我分配 UserInfo() 的变量token : SceneDelegate.swift class SceneDelegate: UIResponder, UIW
在其中一个 SceneDelegate 方法中,我想为另一个 ViewController 中的变量分配一个值。我怎样才能做到这一点?总是为零。我尝试了不同的方法,但由于某种原因它们不起作用,我想使用
*** Terminating app due to uncaught exception 'NSObjectNotAvailableException', reason: 'UIAlertView
我使用 SceneDelegate.swift 来决定使用此代码显示哪个 ViewController: guard let windowScene = (scene as? UIWindowScen
我想在 willConnectTo 中插入一个 func(configureInitialViewController()) (这样我就可以在其他 ViewController 中调用相同的 func
如果应用程序已启动,则 performActionFor ShortcutItem 会在我的 SceneDelegate 中调用,但如果应用程序实际从快捷方式项启动,则不会调用它。这是为什么? 最佳答
我是一名优秀的程序员,十分优秀!