【问题标题】:UIAlertView and UIActionSheet buttonClicked - EXC_BAD_ACCESSUIAlertView 和 UIActionSheet buttonClicked - EXC_BAD_ACCESS
【发布时间】:2013-05-24 13:41:21
【问题描述】:

我收到了两份关于 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

【问题讨论】:

  • 是点击按钮的时候吗?无法连接到真正的方法
  • 当您单击按钮或警报视图或操作表时,似乎会发生这种情况

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


【解决方案1】:

找到这种错误的最好方法使用NSZombieEnabled环境变量。EXC_BAD_ACCESS的原因是试图访问释放的对象。Review this

【讨论】:

    【解决方案2】:

    你可以调试看看异常发生在哪个语句

    1. 点击左侧面板上的“显示断点导航器”

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

    3. 添加异常断点

    4. 完成弹出

    现在它会显示异常声明

    【讨论】:

    • Crashlytics 向我报告此崩溃,一些用户正在经历这种情况,我无法重现它们
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多