无法识别的选择器发送到实例

时间:2011-05-20 13:32:12

标签: iphone objective-c ipad

我在窗口上添加了一个tabbarcontroller,在第一个选项卡上添加了一个按钮。 当我运行应用程序并按下按钮时,应用程序崩溃了这个消息:

2011-05-20 18:56:46.258 FeatureList[3395:207] -[UIViewController barButtonPressed:]: unrecognized selector sent to instance 0x4b22520
2011-05-20 18:56:46.262 FeatureList[3395:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewController barButtonPressed:]: unrecognized selector sent to instance 0x4b22520'
*** Call stack at first throw:
(
    0   CoreFoundation                      0x00da9be9 __exceptionPreprocess + 185
    1   libobjc.A.dylib                     0x00efe5c2 objc_exception_throw + 47
    2   CoreFoundation                      0x00dab6fb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
    3   CoreFoundation                      0x00d1b366 ___forwarding___ + 966
    4   CoreFoundation                      0x00d1af22 _CF_forwarding_prep_0 + 50
    5   UIKit                               0x002b2a6e -[UIApplication sendAction:to:from:forEvent:] + 119
    6   UIKit                               0x003411b5 -[UIControl sendAction:to:forEvent:] + 67
    7   UIKit                               0x00343647 -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
    8   UIKit                               0x003421f4 -[UIControl touchesEnded:withEvent:] + 458
    9   UIKit                               0x002d70d1 -[UIWindow _sendTouchesForEvent:] + 567
    10  UIKit                               0x002b837a -[UIApplication sendEvent:] + 447
    11  UIKit                               0x002bd732 _UIApplicationHandleEvent + 7576
    12  GraphicsServices                    0x016dfa36 PurpleEventCallback + 1550
    13  CoreFoundation                      0x00d8b064 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
    14  CoreFoundation                      0x00ceb6f7 __CFRunLoopDoSource1 + 215
    15  CoreFoundation                      0x00ce8983 __CFRunLoopRun + 979
    16  CoreFoundation                      0x00ce8240 CFRunLoopRunSpecific + 208
    17  CoreFoundation                      0x00ce8161 CFRunLoopRunInMode + 97
    18  GraphicsServices                    0x016de268 GSEventRunModal + 217
    19  GraphicsServices                    0x016de32d GSEventRun + 115
    20  UIKit                               0x002c142e UIApplicationMain + 1160
    21  FeatureList                         0x000024fc main + 102
    22  FeatureList                         0x0000248d start + 53
    23  ???                                 0x00000001 0x0 + 1
)
terminate called after throwing an instance of 'NSException'
Program received signal:  “SIGABRT”.
kill
quit

调试器已退出,状态为0.(gdb)

4 个答案:

答案 0 :(得分:3)

当您尝试调用不存在的方法时会发生这种情况。看起来您已经设置了按钮以向视图控制器发送消息(barButtonPressed :),但是如果您的视图控制器可能没有实现该方法。或者您可能拼错了方法名称,或者没有在方法实现中包含参数。

发布您的视图控制器代码。

答案 1 :(得分:0)

看起来按钮试图在视图控制器上调用barButtonPressed:但该方法不存在。您确定在编译期间没有收到有关丢失方法的警告吗?我的猜测是你没有在nib文件中正确设置视图控制器类。

答案 2 :(得分:0)

您是否已实施barButtonPressed:?你确定你需要结肠吗?请改为barButtonPressed作为选择器名称。

答案 3 :(得分:0)

这是一个老问题,但我想我知道发生了什么。注意错误消息如何显示UIViewController而不是TodayDeal;他需要将Xib的文件所有者从默认的UIViewController更改为TodayDeal