UIButton setImage:forState:在iOS 6上崩溃(SEGV_ACCERR在0x8)

时间:2014-02-25 14:58:05

标签: ios objective-c ios6 uibutton

我收到了iOS 6.X用户的许多崩溃报告。他们中的大多数使用iPod4G,iPhone4S,iPhone4或iPhone3GS。没有iOS 7用户发送崩溃报告。

Exception Type:  SIGSEGV
Exception Codes: SEGV_ACCERR at 0x8
Crashed Thread:  0

Thread 0 Crashed:
0   libobjc.A.dylib                     0x38dca5b0 objc_msgSend + 16
1   Foundation                          0x31ae2a8f __35-[NSISLinearExpression description]_block_invoke_0 + 27
2   CoreFoundation                      0x31103fdf __CFSimpleMergeSort + 47
3   CoreFoundation                      0x3110406b __CFSimpleMergeSort + 187
4   CoreFoundation                      0x31075401 CFSortIndexes + 973
5   CoreFoundation                      0x310af641 -[NSArray sortedArrayFromRange:options:usingComparator:] + 705
6   CoreFoundation                      0x310af313 -[NSArray sortedArrayUsingComparator:] + 59
7   Foundation                          0x31ae29a7 -[NSISLinearExpression description] + 147
8   Foundation                          0x31ae016f __25-[NSISEngine description]_block_invoke_0 + 123
9   Foundation                          0x31ada075 -[NSISEngine enumerateRows:] + 185
10  Foundation                          0x31adffdf -[NSISEngine description] + 123
11  CoreFoundation                      0x3109a897 -[NSObject(NSObject) _copyDescription] + 35
12  CoreFoundation                      0x3110b2db __CFStringAppendFormatCore + 11139
13  CoreFoundation                      0x310a5fa9 CFStringCreateWithFormatAndArguments + 73
14  CoreFoundation                      0x3112a195 +[NSException raise:format:] + 57
15  Foundation                          0x31adc11f -[NSISEngine minimizeConstantInObjectiveRowWithHead:] + 191
16  Foundation                          0x31ade759 -[NSISEngine optimize] + 61
17  Foundation                          0x31ade8af -[NSISEngine withAutomaticOptimizationDisabled:] + 211
18  UIKit                               0x3336bc4f -[UIView(UIConstraintBasedLayout) removeConstraints:] + 283
19  UIKit                               0x32f48451 -[UIView(UIConstraintBasedLayout) invalidateIntrinsicContentSize] + 73
20  UIKit                               0x331b7439 -[UIButton invalidateIntrinsicContentSize] + 61
21  UIKit                               0x32f4863f _UIButtonSetContentForState + 227
22  UIKit                               0x32f4870f -[UIButton setImage:forState:] + 23
23  XXXXX-Messenger                     0x000103bd -[MessageViewController setEditingMode:] (MessageViewController.m:1057)
24  XXXXX-Messenger                     0x0000f973 -[MessageViewController keyboardWasShown:] (MessageViewController.m:882)
25  CoreFoundation                      0x3107b037 _CFXNotificationPost + 1427
26  Foundation                          0x31991599 -[NSNotificationCenter postNotificationName:object:userInfo:] + 73
27  UIKit                               0x32fad879 -[UIInputViewTransition postNotificationsForTransitionStart] + 845
28  UIKit                               0x32fad04f -[UIPeripheralHost(UIKitInternal) executeTransition:] + 923
29  UIKit                               0x32f389a3 -[UIPeripheralHost(UIKitInternal) setInputViews:animationStyle:] + 907
30  UIKit                               0x32f36cbb -[UIResponder becomeFirstResponder] + 475
31  UIKit                               0x330d6e99 -[UITextView becomeFirstResponder] + 361
32  UIKit                               0x33050c41 -[UITextInteractionAssistant(UITextInteractionAssistant_Internal) setFirstResponderIfNecessary] + 121
33  UIKit                               0x33050563 -[UITextInteractionAssistant(UITextInteractionAssistant_Internal) oneFingerTap:] + 1739
34  UIKit                               0x3304fd89 _UIGestureRecognizerSendActions + 129
35  UIKit                               0x330173f5 -[UIGestureRecognizer _updateGestureWithEvent:] + 393
36  UIKit                               0x33204a39 ___UIGestureRecognizerUpdate_block_invoke_0543 + 49
37  UIKit                               0x32f3b82f _UIGestureRecognizerRemoveObjectsFromArrayAndApplyBlocks + 219
38  UIKit                               0x32f3a293 _UIGestureRecognizerUpdate + 1275
39  UIKit                               0x32f451e7 -[UIWindow _sendGesturesForEvent:] + 767
40  UIKit                               0x32f44db3 -[UIWindow sendEvent:] + 91
41  UIKit                               0x32f32801 -[UIApplication sendEvent:] + 381
42  UIKit                               0x32f3211b _UIApplicationHandleEvent + 6155
43  GraphicsServices                    0x34c355a3 _PurpleEventCallback + 591
44  GraphicsServices                    0x34c351d3 PurpleEventCallback + 35
45  CoreFoundation                      0x310ff173 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 35
46  CoreFoundation                      0x310ff117 __CFRunLoopDoSource1 + 139
47  CoreFoundation                      0x310fdf99 __CFRunLoopRun + 1385
48  CoreFoundation                      0x31070ebd CFRunLoopRunSpecific + 357
49  CoreFoundation                      0x31070d49 CFRunLoopRunInMode + 105
50  GraphicsServices                    0x34c342eb GSEventRunModal + 75
51  UIKit                               0x32f86301 UIApplicationMain + 1121
52  XXXXX-Messenger                     0x00015fef main (main.m:16)

这是堆栈跟踪第23行的相关代码

1057: [_actionButton setImage:[UIImage imageNamed:@"conversationSmileyButton.png"] forState:UIControlStateNormal];
1058: [_actionButton setImage:[UIImage imageNamed:@"conversationSmileyButton.png"] forState:UIControlStateHighlighted];

该代码适用于我的所有测试,我无法重现,但我在一周内收到了大约2000份崩溃报告。

有什么想法吗?

根据要求

- (void)setEditingMode:(MessageViewEditingMode)editingMode
{
  _editingMode = editingMode;

  switch (editingMode) {

    //
    // None
    //

    case MessageViewEditingModeNone: {

      // SmileySelector ausblenden, falls vorhanden
      if (_smileySelector != nil && [self.view.subviews indexOfObject:_smileySelector] != NSNotFound) {
        [_smileySelector removeFromSuperview];
      }

      // ActionButton
      [_actionButton setImage:[UIImage imageNamed:@"conversationActionButton.png"] forState:UIControlStateNormal];
      [_actionButton setImage:[UIImage imageNamed:@"conversationActionButton.png"] forState:UIControlStateHighlighted];

      // ComposeView verschieben
      _composeViewMarginBottom.constant = 0.0f;

      // Keyboard ausblenden
      [_composeTextView resignFirstResponder];

    } break;

    //
    // Text
    //

    case MessageViewEditingModeText: {

      // ActionButton
      [_actionButton setImage:[UIImage imageNamed:@"conversationSmileyButton.png"] forState:UIControlStateNormal];
      [_actionButton setImage:[UIImage imageNamed:@"conversationSmileyButton.png"] forState:UIControlStateHighlighted];

      // ComposeView verschieben
      _composeViewMarginBottom.constant = -_keyboardHeight;

      // Keyboard einblenden
      [_composeTextView becomeFirstResponder];

    } break;

    //
    // Smiley
    //

    case MessageViewEditingModeSmiley: {

      // ActionButton
      [_actionButton setImage:[UIImage imageNamed:@"conversationKeyboardButton.png"] forState:UIControlStateNormal];
      [_actionButton setImage:[UIImage imageNamed:@"conversationKeyboardButton.png"] forState:UIControlStateHighlighted];

      // Keyboard ausblenden
      [_composeTextView resignFirstResponder];

      // Anziegen, falls das noch nicht passiert ist
      if ([self.view.subviews indexOfObject:_smileySelector] == NSNotFound) {
        [self.view addSubview:_smileySelector];
      }

    } break;
  }

  // Layout anwenden
  [self.view setNeedsUpdateConstraints];

  [UIView animateWithDuration:0.25 animations:^{
    [self.view layoutIfNeeded];
  }];
}

- (void)keyboardWasShown:(NSNotification*)aNotification
{   
  if (_keyboardAnimationDuration == 0 || _keyboardHeight == 0) {

    NSDictionary* info = [aNotification userInfo];
    CGSize kbSize = [[info objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;

    _keyboardAnimationDuration = [[info objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue];
    _keyboardHeight = kbSize.height;
  }

  self.editingMode = MessageViewEditingModeText;
}

其他信息

我在这里做的是用另一个图像替换现有的UIButton图像(conversationSmileyButton.png)。正如在引发异常之前可以看到的那样(堆栈跟踪线14)存在一些约束操作。也许iOS 6无法正确处理这些限制。 Imo应该有适用于iOS 6的解决方法。

0 个答案:

没有答案