草庐IT

Selector

全部标签

swift - Action 的多个参数/参数 - Swift

我发现了一个与我最相似的问题,但没有得到彻底的回答。如果有人能帮助我,那就太好了。我发现类似问题的地方是here.我很清楚functest()是"test"而test(object:AnyObject)是"测试:"。感谢this.那么2个参数呢?swift不能为“action:”做2个参数吗?funcpopoverSelectedCode(code:AnyObject,desc:AnyObject)我尝试通过以下几种不同的方式对其进行测试,但无济于事:action:"popoverSelectedCode:,"action:"popoverSelectedCode:,:"action:

swift - Action 的多个参数/参数 - Swift

我发现了一个与我最相似的问题,但没有得到彻底的回答。如果有人能帮助我,那就太好了。我发现类似问题的地方是here.我很清楚functest()是"test"而test(object:AnyObject)是"测试:"。感谢this.那么2个参数呢?swift不能为“action:”做2个参数吗?funcpopoverSelectedCode(code:AnyObject,desc:AnyObject)我尝试通过以下几种不同的方式对其进行测试,但无济于事:action:"popoverSelectedCode:,"action:"popoverSelectedCode:,:"action:

ios - Swift 应用程序在 CLLocationManager 上崩溃并显示 `unrecognized selector sent to instance`

与StackOverflow上的许多其他问题类似,在运行我的应用程序时,我遇到了unrecognizedselectorsenttoinstance错误。让我的案例与众不同(我认为)的是它是用Swift编写的,而常见的原因不是这里的原因。在this问题解决方案是在身份检查器中将该View的“自定义类”设置为响应类。我检查了一下,情况确实如此(请注意,我确实在某个时候重命名了该类,但现在它肯定设置为“ViewController”)。我包括下面的堆栈跟踪以及ViewController.swift的代码。您还可以找到所有代码here.我通过重新开始设法避免了这个问题,这使我能够解决我的e

ios - Swift 应用程序在 CLLocationManager 上崩溃并显示 `unrecognized selector sent to instance`

与StackOverflow上的许多其他问题类似,在运行我的应用程序时,我遇到了unrecognizedselectorsenttoinstance错误。让我的案例与众不同(我认为)的是它是用Swift编写的,而常见的原因不是这里的原因。在this问题解决方案是在身份检查器中将该View的“自定义类”设置为响应类。我检查了一下,情况确实如此(请注意,我确实在某个时候重命名了该类,但现在它肯定设置为“ViewController”)。我包括下面的堆栈跟踪以及ViewController.swift的代码。您还可以找到所有代码here.我通过重新开始设法避免了这个问题,这使我能够解决我的e

Swift 4 - 通知中心 addObserver 问题

每次Notification到达并且App尝试执行其关联方法时,我都会崩溃并收到unrecognizedselector错误。这是我的代码-在viewDidLoad中:letnotificationCenter=NotificationCenter.defaultnotificationCenter.addObserver(self,selector:Selector(("sayHello")),name:NSNotification.Name(rawValue:"dataDownloadCompleted"),object:nil)sayHello()方法非常简单-如下所示:func

Swift 4 - 通知中心 addObserver 问题

每次Notification到达并且App尝试执行其关联方法时,我都会崩溃并收到unrecognizedselector错误。这是我的代码-在viewDidLoad中:letnotificationCenter=NotificationCenter.defaultnotificationCenter.addObserver(self,selector:Selector(("sayHello")),name:NSNotification.Name(rawValue:"dataDownloadCompleted"),object:nil)sayHello()方法非常简单-如下所示:func

ios - 选择器与 Action Swift 4

Swift新手。我在下面有两个片段:NotificationCenter.default.addObserver(self,selector:#selector(ViewController.notificationReceived),name:Notification.Name(rawValue:name),object:nil)@objcfuncnotificationReceived(notification:Notification){letx=notification.userInfo!print("\(x["name"]!)")}最后letx:UITapGestureRec

ios - 选择器与 Action Swift 4

Swift新手。我在下面有两个片段:NotificationCenter.default.addObserver(self,selector:#selector(ViewController.notificationReceived),name:Notification.Name(rawValue:name),object:nil)@objcfuncnotificationReceived(notification:Notification){letx=notification.userInfo!print("\(x["name"]!)")}最后letx:UITapGestureRec

swift - [SPApplication _accessibilityInitialize] : unrecognized selector sent to instance on watchOS4

一旦我的watch应用程序启动,它就会崩溃并出现以下错误:2017-08-1713:59:54.304792-0300watchOS4Extension[11500:1617313]-[SPApplication_accessibilityInitialize]:无法识别的选择器发送到实例0x79e5b8f02017-08-1713:59:56.173675-0300watchOS4扩展[11500:1617313]***由于未捕获的异常'NSInvalidArgumentException'而终止应用程序,原因:'-[SPApplication_accessibilityInitia

swift - [SPApplication _accessibilityInitialize] : unrecognized selector sent to instance on watchOS4

一旦我的watch应用程序启动,它就会崩溃并出现以下错误:2017-08-1713:59:54.304792-0300watchOS4Extension[11500:1617313]-[SPApplication_accessibilityInitialize]:无法识别的选择器发送到实例0x79e5b8f02017-08-1713:59:56.173675-0300watchOS4扩展[11500:1617313]***由于未捕获的异常'NSInvalidArgumentException'而终止应用程序,原因:'-[SPApplication_accessibilityInitia