1

在尝试为视图设置动画时,我遇到了一个难以调试的静态库项目问题。
它在调试时工作正常(甚至在发布配置中调试时),但会抛出一个归档为发布的错误:

Exception Type:  EXC_CRASH (SIGSYS)
Exception Codes: 0x00000000, 0x00000000
Crashed Thread:  0

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   TestApp                     0x000d04fc 0x91000 + 259324
1   UIKit                       0x336d777e +[UIView(UIViewAnimationWithBlocks) animateWithDuration:animations:] + 42
2   TestApp                     0x000d04de 0x91000 + 259294
3   TestApp                     0x000d0678 0x91000 + 259704
4   Foundation                  0x355f04f8 __57-[NSNotificationCenter addObserver:selector:name:object:]_block_invoke_0 + 12
5   CoreFoundation              0x35aae540 ___CFXNotificationPost_block_invoke_0 + 64
6   CoreFoundation              0x35a3a090 _CFXNotificationPost + 1400
7   Foundation                  0x355643e4 -[NSNotificationCenter postNotificationName:object:userInfo:] + 60
8   UIKit                       0x33599112 -[UIInputViewTransition postNotificationsForTransitionStart] + 846
9   UIKit                       0x335988cc -[UIPeripheralHost(UIKitInternal) executeTransition:] + 880
10  UIKit                       0x3351bb8c -[UIPeripheralHost(UIKitInternal) setInputViews:animationStyle:] + 304
11  UIKit                       0x3351b260 -[UIPeripheralHost(UIKitInternal) _reloadInputViewsForResponder:] + 952
12  UIKit                       0x3351ae54 -[UIResponder(UIResponderInputViewAdditions) reloadInputViews] + 160
13  UIKit                       0x3351a990 -[UIResponder becomeFirstResponder] + 452
14  UIKit                       0x336194a0 -[UITextInteractionAssistant setFirstResponderIfNecessary] + 168
15  UIKit                       0x33618d6a -[UITextInteractionAssistant oneFingerTap:] + 1602
16  UIKit                       0x33618630 _UIGestureRecognizerSendActions + 100
17  UIKit                       0x335a8d5e -[UIGestureRecognizer _updateGestureWithEvent:] + 298
18  UIKit                       0x337d9472 ___UIGestureRecognizerUpdate_block_invoke_0541 + 42
19  UIKit                       0x33524f4e _UIGestureRecognizerApplyBlocksToArray + 170
20  UIKit                       0x33523a9c _UIGestureRecognizerUpdate + 892
21  UIKit                       0x335307e2 _UIGestureRecognizerUpdateGesturesFromSendEvent + 22
22  UIKit                       0x33530620 -[UIWindow _sendGesturesForEvent:] + 768
23  UIKit                       0x335301ee -[UIWindow sendEvent:] + 82
24  UIKit                       0x3351668e -[UIApplication sendEvent:] + 350
25  UIKit                       0x33515f34 _UIApplicationHandleEvent + 5820
26  GraphicsServices            0x376d5224 PurpleEventCallback + 876
27  CoreFoundation              0x35ab651c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 32
28  CoreFoundation              0x35ab64be __CFRunLoopDoSource1 + 134
29  CoreFoundation              0x35ab530c __CFRunLoopRun + 1364
30  CoreFoundation              0x35a3849e CFRunLoopRunSpecific + 294
31  CoreFoundation              0x35a38366 CFRunLoopRunInMode + 98
32  GraphicsServices            0x376d4432 GSEventRunModal + 130
33  UIKit                       0x33544cce UIApplicationMain + 1074

Thread 0 crashed with ARM Thread State:
    r0: 0x0000004e    r1: 0x000d04f8      r2: 0x338fed47      r3: 0x3f523340
    r4: 0x00000000    r5: 0x2fe8da00      r6: 0x00000001      r7: 0x2fe8d9d0
    r8: 0x3f54cad0    r9: 0x00000000     r10: 0x3fd00000     r11: 0x3f523310
    ip: 0x3f497048    sp: 0x2fe8d988      lr: 0x33539a41      pc: 0x000d04fc
  cpsr: 0x60000010

提供一些背景信息:
静态库是“iOS fake-framework”的一部分,使用此处的模板构建:
https
://github.com/kstenerud/iOS-Universal-Framework 该框架将注册 UI 呈现为模式视图位于客户端应用程序当时正在执行的任何操作之上。它使用客户端应用程序提供的 UIViewController 的句柄推送这些视图。

它没有做任何特别的事情,但这里是动画代码:

-(void)keyboardWillShowNotification:(NSNotification *)notification
{
    double animationDuration = [[[notification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue];

    dispatch_async(dispatch_get_main_queue(), ^(void) {
        [self animateViewsToState:kUMAnimationStateKeyboardVisible forIdiom:[UIDevice currentDevice].userInterfaceIdiom forDuration:animationDuration];
    });
}

-(void)animateViewsToState:(kUMAnimationState)state forIdiom:(UIUserInterfaceIdiom)idiom forDuration:(double)duration
{
    float fieldOffset;    
    if (idiom == UIUserInterfaceIdiomPhone) {
        if (state == kUMAnimationStateKeyboardVisible) {
            fieldOffset = -KEYBOARD_HEIGHT_IPHONE_PORTRAIT;
        } else {
            fieldOffset = KEYBOARD_HEIGHT_IPHONE_PORTRAIT;
        }
    } else {
        if (state == kUMAnimationStateKeyboardVisible) {
            fieldOffset = -IPAD_FIELD_OFFSET;
        } else {
            fieldOffset = IPAD_FIELD_OFFSET;
        }
    }

    [UIView animateWithDuration:duration animations:^(void) {
        mUserNameField.frame = CGRectOffset(mUserNameField.frame, 0, fieldOffset);
        mUserPasswordField.frame = CGRectOffset(mUserPasswordField.frame, 0, fieldOffset);
    }];
}

进一步的 printf 风格调试表明,每当我对 UIKit 做任何事情时它都会崩溃 - 具体来说,当我将 -animateViewsToState 替换为:

if (0 == UIUserInterfaceIdiomPhone) {
    NSLog(@"");
}

[[[[UIAlertView alloc] initWithTitle:@"test" message:@"123" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] autorelease] show];

对我来说,这听起来像是一个链接器问题,但我不明白这些问题如何只在这里出现,而不是事先出现。

任何帮助将不胜感激。

4

0 回答 0