问题描述
当我使用 swiftui 拖出 SignInWithAppleButton 控件时,这是显示的代码。但是,我收到错误消息“传递给不带参数的调用的参数”。编译器只允许在使用 SignInWithAppleButton() 时构建项目。
我在网上找到了很多使用以下格式的代码。为什么现在不起作用?如果不能使用 onRequest 和 onCompletion,正确的替代方法是什么?
SignInWithAppleButton(
onRequest: { request in
},onCompletion: { result in
}
)
解决方法
不久前我也遇到了同样的问题。不幸的是,我不知道如何帮助您,很抱歉,但我很感兴趣地关注了您的问题。感谢发布
,使用 xcode 13.beta,目标 ios 14.5 和 macCatalyst 11.3 在 macos 12.beta 上为我工作。你用的是什么系统?
import SwiftUI
import AuthenticationServices
@main
struct TestApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
struct ContentView: View {
var body: some View {
SignInWithAppleButton(onRequest: { request in
print("onRequest")
},onCompletion: { result in
print("onCompletion")
}
).frame(width: 222,height: 66)
}
}