当点击警报按钮时,应用程序会因崩溃日志而崩溃

时间:2013-10-10 12:55:55

标签: ios uialertview

在我们的项目中,在点击警报视图的按钮时,应用程序会因崩溃日志而崩溃。

示例代码:

 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

1 个答案:

答案 0 :(得分:1)

这通常发生在您分配了一个选择器(在这种情况下是一个警报)但是在选择器中传递的方法不存在的情况下,检查如果您没有使用该方法是公共的目标“self”或者,如果您使用该方法存在的目标“自我”