2016-04-05 9 views
1

Dieser ist mein Code zum Laden von Daten aus dem Array, wenn ich drücken Sie die Taste in der Zell Fehlern gibt amBeenden app aufgrund nicht abgefangene Ausnahme ‚NSInvalidArgumentException‘ Unbekannter Selektor an Instanz 0x7fdab8596b40' gesendet

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 


} 

Taste Aktion Methode

// MARK: Button Action 


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

* ich bin benutzerdefinierte UITableViewCell und UIButton innen UITablebView erstellen Wenn drücken Sie die Taste Fehler unten geben definieren *

012.351.
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 

Antwort

2

Die Aktion hat einen Parameter, so dass die Selektorsignatur tatsächlich takeActionBtn: ist (beachten Sie den Doppelpunkt am Ende). Sie müssen das ändern oder die Schaltfläche wird versuchen, eine Version der Funktion ohne Parameter aufzurufen, der nicht existiert.

+0

Ich probiere es aus, aber arbeite nicht – iParesh

+0

Sie erhalten den gleichen Fehler? Der Text sollte sich leicht geändert haben. Diese Funktion ist in der Steuerung, ja? – Wain

+0

Oben geben Antwort ist Arbeit gut danke für Antwort – iParesh

Verwandte Themen