在ipad上安装应用程序时崩溃,在模拟器中工作正常

时间:2012-05-17 11:12:53

标签: ios cocoa ipad crash

我在申请中遇到以下问题(请帮助我):

    *** Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer position contains NaN: [1.07157e-08 nan]'
    *** Call stack at first throw:
    (
        0   CoreFoundation                      0x3126a64f __exceptionPreprocess + 114
        1   libobjc.A.dylib                     0x32b12c5d objc_exception_throw + 24
        2   CoreFoundation                      0x3126a491 +[NSException raise:format:arguments:] + 68
        3   CoreFoundation                      0x3126a4cb +[NSException raise:format:] + 34
        4   QuartzCore                          0x32c6f61d _ZL18CALayerSetPositionP7CALayerRKN2CA4Vec2IdEEb + 140
        5   QuartzCore                          0x32c6f58b -[CALayer setPosition:] + 38
        6   QuartzCore                          0x32c6f4d7 -[CALayer setFrame:] + 390
        7   UIKit                               0x35a31455 -[UIView(Geometry) setFrame:] + 188
        8   UIKit                               0x35a51743 UIViewCommonInitWithFrame + 594
        9   UIKit                               0x35a514a1 -[UIView initWithFrame:] + 84
        10  CaCaCard                            0x0000683b -[CaCaCardsAppViewController shouldAutorotateToInterfaceOrientation:] + 510
        11  UIKit                               0x35a6eead -[UIViewController _isSupportedInterfaceOrientation:] + 48
        12  UIKit                               0x35a6ee6f -[UINavigationController _doesTopViewControllerSupportInterfaceOrientation:] + 46
        13  UIKit                               0x35a6ee37 -[UINavigationController shouldAutorotateToInterfaceOrientation:] + 14
        14  UIKit                               0x35a6edbf -[UINavigationController _isSupportedInterfaceOrientation:] + 54
        15  UIKit                               0x35a6fbbb -[UIViewController window:shouldAutorotateToInterfaceOrientation:] + 46
        16  UIKit                               0x35a6f857 -[UIWindow _shouldAutorotateToInterfaceOrientation:] + 194
        17  UIKit                               0x35a6f4a3 -[UIWindow setAutorotates:forceUpdateInterfaceOrientation:] + 366
        18  UIKit                               0x35a6f0ad -[UIWindow setDelegate:] + 168
        19  UIKit                               0x35a6efa9 -[UIViewController _tryBecomeRootViewControllerInWindow:] + 64
        20  UIKit                               0x35a6d611 -[UIViewController viewDidMoveToWindow:shouldAppearOrDisappear:] + 460
        21  UIKit                               0x35a6d3e5 -[UINavigationController viewDidMoveToWindow:shouldAppearOrDisappear:] + 36
        22  UIKit                               0x35a4c5a7 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 506
        23  UIKit                               0x35a4c32f -[UIView(Hierarchy) _postMovedFromSuperview:] + 106
        24  UIKit                               0x35a31c1b -[UIView(Internal) _addSubview:positioned:relativeTo:] + 678
        25  UIKit                               0x35a3196b -[UIView(Hierarchy) addSubview:] + 22
        26  CaCaCard                            0x00004bcf -[CaCaCardsAppAppDelegate application:didFinishLaunchingWithOptions:] + 318
        27  UIKit                               0x35a61821 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 772
        28  UIKit                               0x35a5bb65 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 272
        29  UIKit                               0x35a307d7 -[UIApplication handleEvent:withNewEvent:] + 1114
        30  UIKit                               0x35a30215 -[UIApplication sendEvent:] + 44
        31  UIKit                               0x35a2fc53 _UIApplicationHandleEvent + 5090
        32  GraphicsServices                    0x31d37e77 PurpleEventCallback + 666
        33  CoreFoundation                      0x31241a97 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 26
        34  CoreFoundation                      0x3124383f __CFRunLoopDoSource1 + 166
        35  CoreFoundation                      0x3124460d __CFRunLoopRun + 520
        36  CoreFoundation                      0x311d4ec3 CFRunLoopRunSpecific + 230
        37  CoreFoundation                      0x311d4dcb CFRunLoopRunInMode + 58
        38  UIKit                               0x35a5ad49 -[UIApplication _run] + 372
        39  UIKit                               0x35a58807 UIApplicationMain + 670
        40  CaCaCard                            0x000028e7 main + 70
        41  CaCaCard                            0x0000289c start + 40
    )
    terminate called after throwing an instance of 'NSException'
    Program received signal:  “SIGABRT”.
    warning: Unable to read symbols for /Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.3.5 (8L1)/Symbols/Developer/usr/lib/libXcod

eDebuggerSupport.dylib (file not found).
(gdb) 

-(void) viewWillAppear:(BOOL)animated
//-----------------------------------
{   
    if ( self.interfaceOrientation == UIInterfaceOrientationPortrait ||
        self.interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown  )
    {
        [NSThread sleepForTimeInterval:0.5];

        [UIView beginAnimations:@"View Flip" context:nil];
        [UIView setAnimationDuration:1.25];
        [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];

        [[UIApplication sharedApplication] setStatusBarOrientation:
         UIInterfaceOrientationLandscapeRight];

        UIScreen *screen = [UIScreen mainScreen];
        CGFloat screenWidth = screen.bounds.size.width;
        CGFloat screenHeight = screen.bounds.size.height;
        UIView *navView = [[self navigationController] view];
        navView.bounds = CGRectMake(0, 0, screenHeight, screenWidth);
        navView.transform = CGAffineTransformIdentity;
        navView.transform = CGAffineTransformMakeRotation(degreesToRadian(90));
        navView.center = CGPointMake(screenWidth/2.0, screenHeight/2.0);

        [UIView commitAnimations];

    }

    fontSelected = NO;

}

1 个答案:

答案 0 :(得分:1)

问题是您在某个时刻设置的帧大小无效。可能是某个地方零值的矩形。

从您的代码中我怀疑当您要求屏幕尺寸时,您会收到一些意想不到的值。

也不要使用那些旧的动画功能。使用基于块的动画。它好多了。