![](/img/trans.png)
[英]iOS - Error : unrecognized selector sent to instance in PrepareForSegue:
[英]iOS unrecognized selector sent to instance error
我在LoginViewController处添加一个按钮。 这是LoginViewComtroller中的代码
loginButton?.addTarget(self, action: #selector(LoginViewController.wechatLogin), for: .touchDown)
func wechatLogin() {
sendWXAuthRequest()
}
func sendWXAuthRequest() {
print("hello")
let req: SendAuthReq = SendAuthReq()
req.scope = "snsapi_userinfo,snsapi_base"
WXApi.send(req)
}
func onResp(_ resp: BaseResp!) {
print(resp)
}
这是AppDelegate.swift中的代码
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
//register
buildKeyWindow()
let right = WXApi.registerApp("My_Appid")
print(right)
return true
}
func application(_ application: UIApplication, handleOpen url: URL) -> Bool {
return WXApi.handleOpen(url, delegate: self)
}
func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
return WXApi.handleOpen(url, delegate: self)
}
当我第一次运行该应用程序时,进入微信时会显示错误消息。 然后我第二次运行它,有一个错误,说“无法识别的选择器发送到实例”
尝试在-all_load
-force_load
的Other Linker Flags
-force_load
更改为-force_load
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.