我做了一个小型原型,它使用 Firebase Cloud Messaging 和新的 SwiftUI 2 应用程序生命周期。我添加了一个自定义 AppDelegate via\n@UIApplicationDelegateAdaptor(AppDelegate.self) var delegate并禁用了方法调配以使 FCM 能够工作。一切都按预期进行。
今天一位同事问我是否可以通过UIApplication.shared.delegate. 所以我试了一下,发现似乎有两个不同的 AppDelegate 对象:
po delegate印刷:
<MyProject.AppDelegate: 0x6000009183c0>\nRun Code Online (Sandbox Code Playgroud)\n其中po UIApplication.shared.delegate打印:
\xe2\x96\xbf Optional<UIApplicationDelegate>\n \xe2\x96\xbf some : <SwiftUI.AppDelegate: 0x600000b58ca0>\nRun Code Online (Sandbox Code Playgroud)\n现在我想知道访问 AppDelegate 的正确方法是什么?应该通过 an 获取它@EnvironmentalObject并将其传递给所有视图吗?或者通过使用老式的方式UIApplication?\n另外我想了解为什么我最终会得到两个 AppDelegate。
I'm currently facing an issue with compositional layout which can also be seen in Apple's example -> ConferenceNewsFeedViewController. The item height is set to .estimated(100) and the width is set to .fractionalWidth(1.0). On the initial display the cell is not wrapping the label content. Only if you begin to scroll the layout of the cells are corrected. Does anybody know how to fix this issue?
Here is the incorrect layout:
Here is the layout after scrolling:
I know that …
ios uicollectionview uicollectionviewlayout swift uicollectionviewcompositionallayout