gpt4 book ai didi

swift - 由于未捕获的异常 'NSInvalidArgumentException' 无法识别的选择器发送到实例 0x7fdab8596b40' 而终止应用程序

转载 作者:搜寻专家 更新时间:2023-11-01 07:25:45 24 4
gpt4 key购买 nike

这是我在单元格中按下按钮时从数组加载数据的代码,出现错误

func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return self.ncNo.count
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! NCReceivedCell

cell.labelNCNo.text = self.ncNo[indexPath.section]
cell.labelDescription.text = self.desc[indexPath.section]
cell.labelStatus.text = self.status[indexPath.section]
cell.takeAction.tag = indexPath.section

cell.takeAction.addTarget(self, action: "takeActionBtn", forControlEvents: UIControlEvents.TouchUpInside)

cell.backgroundColor = UIColor(white:1, alpha: 0.5)
cell.layer.cornerRadius = 15
cell.accessoryType = UITableViewCellAccessoryType.DisclosureIndicator
return cell


}

按钮操作方法

// MARK: Button Action


@IBAction func takeActionBtn(sender: UIButton) {
print("Hello")
}

*我在 UITablebView 中创建自定义 UITableViewCell 和 UIButton 当按下按钮时给出下面定义的错误 *

2016-04-05 11:55:23.679 QMS360[1384:51274] -[QMS360.NCReceivedVC takeActionBtn]: unrecognized selector sent to instance 0x7fdab8596b40
2016-04-05 11:55:23.691 QMS360[1384:51274] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[QMS360.NCReceivedVC takeActionBtn]: unrecognized selector sent to instance 0x7fdab8596b40'
*** First throw call stack:
(
0 CoreFoundation 0x0000000108e3fe65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x00000001088b6deb objc_exception_throw + 48
2 CoreFoundation 0x0000000108e4848d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x0000000108d9590a ___forwarding___ + 970
4 CoreFoundation 0x0000000108d954b8 _CF_forwarding_prep_0 + 120
5 UIKit 0x0000000109418194 -[UIApplication sendAction:to:from:forEvent:] + 92
6 UIKit 0x00000001095876fc -[UIControl sendAction:to:forEvent:] + 67
7 UIKit 0x00000001095879c8 -[UIControl _sendActionsForEvents:withEvent:] + 311
8 UIKit 0x0000000109586af8 -[UIControl touchesEnded:withEvent:] + 601
9 UIKit 0x00000001098f0ede _UIGestureRecognizerUpdate + 10279
10 UIKit 0x0000000109486f8a -[UIWindow _sendGesturesForEvent:] + 1137
11 UIKit 0x00000001094881c0 -[UIWindow sendEvent:] + 849
12 UIKit 0x0000000109436b66 -[UIApplication sendEvent:] + 263
13 UIKit 0x0000000109410d97 _UIApplicationHandleEventQueue + 6844
14 CoreFoundation 0x0000000108d6ba31 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
15 CoreFoundation 0x0000000108d6195c __CFRunLoopDoSources0 + 556
16 CoreFoundation 0x0000000108d60e13 __CFRunLoopRun + 867
17 CoreFoundation 0x0000000108d60828 CFRunLoopRunSpecific + 488
18 GraphicsServices 0x000000010cabbad2 GSEventRunModal + 161
19 UIKit 0x0000000109416610 UIApplicationMain + 171
20 QMS360 0x0000000107c926dd main + 109
21 libdyld.dylib 0x000000010c5ef92d start + 1
22 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

最佳答案

该操作有一个参数,因此选择器签名实际上是 takeActionBtn:(注意末尾的冒号)。您需要更改它,否则按钮将尝试调用不存在的不带参数的函数版本。

关于swift - 由于未捕获的异常 'NSInvalidArgumentException' 无法识别的选择器发送到实例 0x7fdab8596b40' 而终止应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36418852/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com