iOS无法识别的选择器发送到实例错误
我在LoginViewController添加一个按钮。 这里是LoginViewComtrolleriOS无法识别的选择器发送到实例错误
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)
}
当我第一次运行该应用程序,有一个错误显示,当我进入微信。 然后我第二次运行它,有一些错误,说“无法识别的选择发送到实例”
尝试在您栋设置Other Linker Flags
改变-all_load
到-force_load
我添加了-Obj-C .... –
然后解决它.... –
在这里使用Xcode 8.3和微信iOS SDK 1.7.7,'-Obj-c'和'-force_load'都不起作用,但'' - all_load'固定的问题。 – Lien
当我注释掉WXApi.registerApp(“My_Appid”)。除了启用按钮,一切都可以。 –