1

在我们的项目中,当点击警报视图的按钮时,应用程序崩溃并显示以下崩溃日志。

示例代码:

 UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Alert" message:@"Room has been checked out.  Please contact Front desk." delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
            [alertView show];



- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    [[NSNotificationCenter defaultCenter] postNotificationName:@"TestNotification" object:nil];
}

崩溃日志:

Date/Time:       2013-10-10 17:51:11.390 +0530
OS Version:      iOS 6.1.3 (10B329)
Report Version:  104

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x62694c37
Crashed Thread:  0

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   libobjc.A.dylib                 0x3b8455b0 objc_msgSend + 16
1   UIKit                           0x357abe7c -[UIWindow firstResponder] + 64
2   UIKit                           0x3581966c -[UIWindow _makeKeyWindowIgnoringOldKeyWindow:] + 300
3   UIKit                           0x357be2b0 -[UIResponder resignFirstResponder] + 384
4   UIKit                           0x358ff71a -[UIAlertView(Private) resignFirstResponder] + 38
5   UIKit                           0x358ff292 -[UIAlertView(Private) _performPopoutAnimationAnimated:coveredBySpringBoardAlert:] + 434
6   UIKit                           0x358920c0 -[UIApplication sendAction:to:from:forEvent:] + 68
7   UIKit                           0x35892072 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 26
8   UIKit                           0x35892050 -[UIControl sendAction:to:forEvent:] + 40
9   UIKit                           0x35891906 -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 498
10  UIKit                           0x35891dfc -[UIControl touchesEnded:withEvent:] + 484
11  UIKit                           0x357ba5ec -[UIWindow _sendTouchesForEvent:] + 520
12  UIKit                           0x357a77fc -[UIApplication sendEvent:] + 376
13  UIKit                           0x357a7116 _UIApplicationHandleEvent + 6150
....

xcode 控制台中的异常:

2013-10-10 18:34:05.910 MyProject[1423:907] -[OS_dispatch_queue _windowBecameKey]: unrecognized selector sent to instance 0x1dd8ac10
4

1 回答 1

1

这通常发生在您分配了一个选择器(在本例中为警报)但在选择器中传递的方法不存在时,请检查您是否没有将方法用作公共的目标“自我”或者如果您正在使用该方法存在的目标“自我”

于 2013-10-10T13:09:06.410 回答