Мы разрабатываем приложение SwiftUI watchOS и хотим поддерживать вход с помощью функций Apple. Поскольку для него нет компонента SwiftUI, мы используем WKInterfaceObjectRepresentable для показа. Первоначально это было показано в качестве первого представления с другими параметрами входа, и у нас не было проблем, но затем мы решили добавить их в некоторые потоки навигации, и он начал обрабатывать sh.
Просто чтобы уточнить, приведенный ниже код работает:
struct QWSplashScreenView: View {
@State var showLogin: Bool = true
var body: some View {
QWSignInView(showEmailLogin: self.$showLogin)
}
}
Хотя этот код не работает:
struct QWSplashScreenView: View {
@State var showLogin: Bool = true
var body: some View {
NavigationLink(destination: QWSignInView(showEmailLogin: self.$showLogin), label: { Text("Login") })
}
}
Cra sh полностью на уровне системы, просто чтобы показать его начальную часть:
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 com.apple.SwiftUI 0x010d33d2 static PlatformViewRepresentableAdaptor.platformView(for:) + 50
1 com.apple.SwiftUI 0x010d3c8c protocol witness for static PlatformViewRepresentable.platformView(for:) in conformance PlatformViewRepresentableAdaptor<A> + 28
2 com.apple.SwiftUI 0x011d7d5b PlatformViewHost.representedView.getter + 27
3 com.apple.SwiftUI 0x011e68f4 PlatformViewHost.init(_:host:environment:viewPhase:) + 340
4 com.apple.SwiftUI 0x011e2a8e PlatformViewHost.__allocating_init(_:host:environment:viewPhase:) + 46
5 com.apple.SwiftUI 0x011e235e closure #1 in PlatformViewChild.update(context:) + 1662
6 com.apple.SwiftUI 0x011ddaa9 PlatformViewChild.update(context:) + 553
7 com.apple.SwiftUI 0x011e4057 protocol witness for static UntypedAttribute._update(_:graph:attribute:) in conformance PlatformViewChild<A> + 39
8 com.apple.AttributeGraph 0x035c0791 partial apply + 33
9 com.apple.AttributeGraph 0x035a8d99 AG::Graph::UpdateStack::update() + 461
Кто-нибудь видел такое поведение? (То же самое происходит sh, если я тоже использую лист)
Код QWSignInView:
struct QWSignInView: View {
@Binding var showEmailLogin: Bool
var body: some View {
VStack {
Text("Record and save your blood pressure measurements")
VStack() {
QWSignInWithAppleButton()
.frame(height:40)
Button(action: {
self.showEmailLogin = true
}) {
Text("I have an account")
}
}
}
}
}
И QWSignInWithAppleButton:
final class QWSignInWithAppleButton: WKInterfaceObjectRepresentable {
typealias WKInterfaceObjectType = WKInterfaceAuthorizationAppleIDButton
func makeWKInterfaceObject(context: WKInterfaceObjectRepresentableContext<QWSignInWithAppleButton>) -> WKInterfaceAuthorizationAppleIDButton {
WKInterfaceAuthorizationAppleIDButton(target: context.coordinator, action: #selector(Coordinator.buttonPressed))
}
func updateWKInterfaceObject(_ wkInterfaceObject: WKInterfaceAuthorizationAppleIDButton, context: WKInterfaceObjectRepresentableContext<QWSignInWithAppleButton>) {
}
func makeCoordinator() -> Coordinator {
return Coordinator()
}
class Coordinator {
@objc func buttonPressed() {
appStore.loginStore.beginAppleIDSignIn()
}
}
}