CALayerInvalidGeometry异常 - CALayer位置包含NaN

时间:2014-05-30 09:11:26

标签: ios exception ios7 calayer nan

我在应用程序启动期间收到CALayerInvalidGeometry异常。这个问题仅适用于Iphone 5s。其他Iphone / iPad / Simulator版本没有这样的例外。

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.interactionSearchDrugs = [[NSMutableSet alloc] init];

    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

    [MediDosesContainer sharedInstance];
    UIViewController *viewController1, *viewController2, *viewController3, *viewController4;
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
        viewController1 = [[MediScheduleViewController alloc] initWithNibName:@"MediScheduleViewController" bundle:nil];
        viewController2 = [[GraphViewController alloc] initWithNibName:@"GraphViewController" bundle:nil];
        viewController3 = [[DrugSearchViewController alloc] initWithNibName:@"DrugSearchViewController" bundle:nil];
        viewController4 = [[MediSettingsViewController alloc] initWithNibName:@"MediSettingsViewController" bundle:nil];

        self.tabBarController = [[CustomTabBarViewController alloc] init];
        if (NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_6_1) {
            [self.tabBarController.tabBar setBarStyle:UIBarStyleBlack];
            self.tabBarController.tabBar.translucent = NO;
        }

        NSMutableArray *controllers = [[NSMutableArray alloc] initWithCapacity:4];
        [controllers addObject:[[UINavigationController alloc] initWithRootViewController:viewController1]];
        [controllers addObject:[[UINavigationController alloc] initWithRootViewController:viewController2]];
        [controllers addObject:[[UINavigationController alloc] initWithRootViewController:viewController3]];
        [controllers addObject:[[UINavigationController alloc] initWithRootViewController:viewController4]];

        self.tabBarController.viewControllers = controllers;

        for (int i = 0; i < self.tabBarController.viewControllers.count; i++) {
            UINavigationController *navVC = [self.tabBarController.viewControllers objectAtIndex:i];
            navVC.navigationBarHidden = YES;

            [[self.tabBarController.tabBar.items objectAtIndex:i] setTitlePositionAdjustment:UIOffsetMake(0, -4.0)];
        }

        self.window.rootViewController = self.tabBarController;

    } else {

        ContainerViewController *containerVC = [[ContainerViewController alloc] initWithNibName:@"ContainerViewController" bundle:nil];
        self.containerVC = containerVC;

        self.window.rootViewController = self.containerVC;
    }

    application.applicationIconBadgeNumber = 0;

    [self.window makeKeyAndVisible];

    return YES;
}

包含[[UINavigationController alloc] initWithRootViewController:viewControllerX]];的行引发异常更重要的是,即使我用自定义UIViewController替换自定义视图控制器,问题仍然存在。

控制台输出:

2014-05-29 15:45:31.805 mediapp[3614:60b] *** Terminating app due to uncompahgryt exception 'CALayerInvalidGeometry', reason: 'CALayer position contains NaN: [nan 4.94066e-323]'
*** First throw call stack:
(0x18c37b09c 0x1982f9d78 0x18c37afdc 0x18ee3e07c 0x18ee3dfd0 0x18ee3df60 0x18f2474f4    0x18f25e040 0x18f2e5d38 0x18f252550 0x18f2abea4 0x10024c484 0x18f2e5ba4 0x18f2e59a0 0x18f2e5368 0x18f2e5288 0x18f2e4efc 0x18f2500d8 0x18f250044 0x18f2e4998 0x18f34462c 0x1000dbe70 0x18f2c55cc 0x18f2c4fb8 0x18f2be9a0 0x18f251530 0x18f250720 0x18f2be0b0 0x191ca1128 0x191ca0c54 0x18c33afc8 0x18c33af28 0x18c33914c 0x18c279b38 0x18f2bd2d4 0x18f2b80e8 0x1000db7ac 0x1988e3aa0)
libc++abi.dylib: terminating with uncaught exception of type NSException

堆栈跟踪:

Thread 1, Queue : com.apple.main-thread
#0  0x00000001989de58c in __pthread_kill ()
#1  0x0000000198a614a8 in pthread_kill ()
#2  0x000000019897284c in abort ()
#3  0x0000000197b98994 in abort_message ()
#4  0x0000000197bb5c2c in default_terminate_handler() ()
#5  0x00000001982fa028 in _objc_terminate() ()
#6  0x0000000197bb3168 in std::__terminate(void (*)()) ()
#7  0x0000000197bb2a80 in __cxa_throw ()
#8  0x00000001982f9e94 in objc_exception_throw ()
#9  0x000000018c37afdc in +[NSException raise:format:] ()
#10 0x000000018ee3e07c in CA::Layer::set_position(CA::Vec2<double> const&, bool) ()
#11 0x000000018ee3dfd0 in -[CALayer setPosition:] ()
#12 0x000000018ee3df60 in -[CALayer setFrame:] ()
#13 0x000000018f2474f4 in -[UIView(Geometry) setFrame:] ()
#14 0x000000018f25e040 in -[UIImageView _setViewGeometry:forMetric:] ()
#15 0x000000018f2e5d38 in -[_UINavigationBarBackground _setFrame:forceUpdateBackgroundImage:] ()
#16 0x000000018f252550 in -[UIView initWithFrame:] ()
#17 0x000000018f2abea4 in -[UIImageView initWithFrame:] ()
#18 0x000000010024c484 in __42+[ARLocateSpecialViews initWithFrameRock:]_block_invoke ()
#19 0x000000018f2e5ba4 in -[_UINavigationBarBackground initWithFrame:barStyle:barTintColor:appearance:barTranslucence:] ()
#20 0x000000018f2e59a0 in -[UINavigationBar _commonNavBarInit] ()
#21 0x000000018f2e5368 in -[UINavigationBar initWithFrame:] ()
#22 0x000000018f2e5288 in -[UINavigationController navigationBar] ()
#23 0x000000018f2e4efc in -[UINavigationController loadView] ()
#24 0x000000018f2500d8 in -[UIViewController loadViewIfRequired] ()
#25 0x000000018f250044 in -[UIViewController view] ()
#26 0x000000018f2e4998 in -[UINavigationController pushViewController:transition:forceImmediate:] ()
#27 0x000000018f34462c in -[UINavigationController initWithRootViewController:] ()
#28 0x00000001000dbe70 in -[MediAppDelegate application:didFinishLaunchingWithOptions:] at /Users/mateuszmurawski/Projekty/Medi/Medi/MediAppDelegate.m:59
#29 0x000000018f2c55cc in -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] ()
#30 0x000000018f2c4fb8 in -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] ()
#31 0x000000018f2be9a0 in -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] ()
#32 0x000000018f251530 in -[UIApplication handleEvent:withNewEvent:] ()
#33 0x000000018f250720 in -[UIApplication sendEvent:] ()
#34 0x000000018f2be0b0 in _UIApplicationHandleEvent ()
#35 0x0000000191ca1128 in _PurpleEventCallback ()
#36 0x0000000191ca0c54 in PurpleEventCallback ()
#37 0x000000018c33afc8 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ ()
#38 0x000000018c33af28 in __CFRunLoopDoSource1 ()
#39 0x000000018c33914c in __CFRunLoopRun ()
#40 0x000000018c279b38 in CFRunLoopRunSpecific ()
#41 0x000000018f2bd2d4 in -[UIApplication _run] ()
#42 0x000000018f2b80e8 in UIApplicationMain ()
#43 0x00000001000db7ac in main at /Users/mateuszmurawski/Projekty/Medi/Medi/main.m:16
#44 0x00000001988e3aa0 in start ()

0 个答案:

没有答案