我有一个基于SwiftUI的本地WatchOS应用。我有4个视图,用户可以左右滑动以进入。此功能不是直接的SwiftUI功能,因此我使用的是WKInterfaceController.reloadRootConrollers(withNamesandContext :)。但是,有时屏幕在滑动时仅加载空白屏幕。我看不到这段代码有什么问题...
import WatchKit
import Foundation
import SwiftUI
class HostingController : WKHostingController<MeetingView> {
override init(){
super.init()
displayViews()
}
func displayViews() {
WKInterfaceController.reloadRootControllers(withNamesAndContexts: [
(name: "OneViewController", context: [:] as AnyObject),
(name: "TwoViewController", context: [:] as AnyObject),
(name: "ThreeViewController", context: [:] as AnyObject),
(name: "FourViewController", context: [:] as AnyObject),
])
}
override var body: MainView {
return MainView()
}
}
答案 0 :(得分:1)
这里有同样的问题。使用情节提要时也会发生。
答案 1 :(得分:0)
似乎是WatchOS的错误,这不再是问题。