UIAlertView和UIActionSheet buttonClicked - EXC_BAD_ACCESS

时间:2013-05-24 13:41:21

标签: ios uialertview exc-bad-access uiactionsheet crashlytics

我收到了两篇关于Crashlytics的崩溃报告,其中包含类似的日志,一个针对UIAlertView,另一个针对UIActionSheet

Exception Type: EXC_BAD_ACCESS Code: KERN_INVALID_ADDRESS at 0xa0000008

0    libobjc.A.dylib     objc_msgSend + 15
1    UIKit   -[UIAlertView(Private) _buttonClicked:] + 296
2    UIKit   -[UIApplication sendAction:to:from:forEvent:] + 72
3    UIKit   -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 30
4    UIKit   -[UIControl sendAction:to:forEvent:] + 44
5    UIKit   -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 502
6    UIKit   -[UIControl touchesEnded:withEvent:] + 488
7    UIKit   -[UIWindow _sendTouchesForEvent:] + 524
8    UIKit   -[UIApplication sendEvent:] + 380
9    UIKit   _UIApplicationHandleEvent + 6154
10   GraphicsServices    _PurpleEventCallback + 590
11   GraphicsServices    PurpleEventCallback + 34
12 ...   CoreFoundation  __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 34

我正在使用ARC,在我的代码中,我在视图控制器中将委托设置为self来分配/初始化警报视图和操作表。我找不到问题的根源,有什么建议吗?

这是SomeViewController.m中的一个示例:

UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:NSLocalizedString(@"Are you sure?", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"Continue",nil) destructiveButtonTitle:NSLocalizedString(@"Yes", nil) otherButtonTitles:nil];
            actionSheet.delegate = self;
            [actionSheet showInView:self.view];

结束我实施(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex

2 个答案:

答案 0 :(得分:2)

查找此类错误的最佳方法使用NSZombieEnabled环境变量。EXC_BAD_ACCESS因为尝试访问已发布的对象。Review this

答案 1 :(得分:0)

您可以调试以查看异常发生的语句

  1. 点击左侧面板上的“show breakpoint navigator”

  2. 点击面板下方的+按钮

  3. 添加例外断点

  4. 完成弹出

  5. 现在它将显示异常声明