按钮捕获类型为 NSException 按钮的异常

button ncaught exception of type NSException button

当我点击这个按钮时出现错误:

2016-10-20 18:33:11.229 FoodTracker[30127:1716662] -[FoodTracker.Rating_controller ratingButtonTapped:]: unrecognized selector sent to instance 0x7f86ac905af0
2016-10-20 18:33:11.648 FoodTracker[30127:1716662] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[FoodTracker.Rating_controller ratingButtonTapped:]: unrecognized selector sent to instance 0x7f86ac905af0'
*** First throw call stack:
(
    0   CoreFoundation                      0x0000000110d7934b __exceptionPreprocess + 171
    1   libobjc.A.dylib                     0x000000010e0da21e objc_exception_throw + 48
    2   CoreFoundation                      0x0000000110de8f34 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
    3   CoreFoundation                      0x0000000110cfec15 ___forwarding___ + 1013
    4   CoreFoundation                      0x0000000110cfe798 _CF_forwarding_prep_0 + 120
    5   UIKit                               0x000000010e5abb88 -[UIApplication sendAction:to:from:forEvent:] + 83
    6   UIKit                               0x000000010e7312b2 -[UIControl sendAction:to:forEvent:] + 67
    7   UIKit                               0x000000010e7315cb -[UIControl _sendActionsForEvents:withEvent:] + 444
    8   UIKit                               0x000000010e72ff83 -[UIControl touchesBegan:withEvent:] + 414
    9   UIKit                               0x000000010e618e15 -[UIWindow _sendTouchesForEvent:] + 2043
    10  UIKit                               0x000000010e61a7c3 -[UIWindow sendEvent:] + 4011
    11  UIKit                               0x000000010e5c7a33 -[UIApplication sendEvent:] + 371
    12  UIKit                               0x000000010edb9b6d __dispatchPreprocessedEventFromEventQueue + 3248
    13  UIKit                               0x000000010edb2817 __handleEventQueue + 4879
    14  CoreFoundation                      0x0000000110d1e311 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    15  CoreFoundation                      0x0000000110d0359c __CFRunLoopDoSources0 + 556
    16  CoreFoundation                      0x0000000110d02a86 __CFRunLoopRun + 918
    17  CoreFoundation                      0x0000000110d02494 CFRunLoopRunSpecific + 420
    18  GraphicsServices                    0x0000000112c28a6f GSEventRunModal + 161
    19  UIKit                               0x000000010e5a9f34 UIApplicationMain + 159
    20  FoodTracker                         0x000000010daf4a2f main + 111
    21  libdyld.dylib                       0x0000000111ca368d start + 1
    22  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

应该有 ratingButtonTapped: IBAction,它存在于您的 xib/storyboard 中,但未在代码中实现。只需 select 您的按钮并打开 Connections inspector 选项卡:

确保您在 class 中实现了指定的方法,或者删除您没有实现的所有 IBAction。