Objective c CALayerInvalidGeometry'CALayerInvalidGeometry'

Objective c CALayerInvalidGeometry'CALayerInvalidGeometry',objective-c,ios,xcode,cloudmade,uitabview,Objective C,Ios,Xcode,Cloudmade,Uitabview,我正在制作一个选项卡式视图应用程序,并使用CloudMake的API。 我在单视图应用程序中有一个工作项目,我尝试将其复制到选项卡式视图应用程序 我复制并粘贴了所有内容,设置了项目首选项和所有内容。 选项卡式视图FirstViewController与较早的单视图应用程序完全相同。 然而,当我运行应用程序时,会出现以下错误: Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer b

我正在制作一个选项卡式视图应用程序,并使用CloudMake的API。 我在单视图应用程序中有一个工作项目,我尝试将其复制到选项卡式视图应用程序

我复制并粘贴了所有内容,设置了项目首选项和所有内容。 选项卡式视图FirstViewController与较早的单视图应用程序完全相同。 然而,当我运行应用程序时,会出现以下错误:

Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer bounds contains NaN: [inf inf; nan nan]'
我试着用谷歌搜索,但什么也没找到。这是我的第一个选项卡式视图应用程序,所以我不确定是否有我需要注意的东西。 我甚至不确定要在这里粘贴什么代码段或错误报告。 任何帮助都将不胜感激! 非常感谢

编辑2:我认为这是异常堆栈跟踪:

2012-02-28 23:51:00.720 ParkerAssistant[1454:f803] CRASH: CALayer bounds contains NaN: [inf inf; nan nan]
2012-02-28 23:51:00.725 ParkerAssistant[1454:f803] Stack Trace: (
    0   CoreFoundation                      0x0156606e __exceptionPreprocess + 206
    1   libobjc.A.dylib                     0x01b1ad0a objc_exception_throw + 44
    2   CoreFoundation                      0x0150ea78 +[NSException raise:format:arguments:] + 136
    3   CoreFoundation                      0x0150e9e9 +[NSException raise:format:] + 57
    4   QuartzCore                          0x001df137 _ZN2CA5Layer10set_boundsERKNS_4RectEb + 215
    5   QuartzCore                          0x001d52fa -[CALayer setBounds:] + 156
    6   ParkerAssistant                     0x0003ee9a -[RMPath recalculateGeometry] + 927
    7   ParkerAssistant                     0x00002f55 -[ParkerAssistantFirstViewController viewDidLoad] + 1397
    8   UIKit                               0x003fd64e -[UIViewController view] + 184
    9   UIKit                               0x00418b89 -[UITabBarController transitionFromViewController:toViewController:transition:shouldSetSelected:] + 105
    10  UIKit                               0x004189bd -[UITabBarController transitionFromViewController:toViewController:] + 63
    11  UIKit                               0x00416f8a -[UITabBarController _setSelectedViewController:] + 339
    12  UIKit                               0x00416e2f -[UITabBarController setSelectedViewController:] + 169
    13  UIKit                               0x00414ffb -[UITabBarController _selectDefaultViewControllerIfNecessaryWithAppearanceTransitions:] + 192
    14  UIKit                               0x0041585a -[UITabBarController viewWillAppear:] + 148
    15  UIKit                               0x003fefbf -[UIViewController _setViewAppearState:isAnimating:] + 158
    16  UIKit                               0x003ff21b -[UIViewController __viewWillAppear:] + 62
    17  UIKit                               0x004000f1 -[UIViewController viewWillMoveToWindow:] + 253
    18  UIKit                               0x0036efec -[UIView(Hierarchy) _willMoveToWindow:withAncestorView:] + 592
    19  UIKit                               0x00374572 -[UIView(Internal) _addSubview:positioned:relativeTo:] + 388
    20  UIKit                               0x0036e72b -[UIView(Hierarchy) addSubview:] + 56
    21  UIKit                               0x0035dbc2 -[UIWindow addRootViewControllerViewIfPossible] + 380
    22  UIKit                               0x0035dce2 -[UIWindow _setHidden:forced:] + 280
    23  UIKit                               0x0035dea8 -[UIWindow _orderFrontWithoutMakingKey] + 49
    24  UIKit                               0x00364d9a -[UIWindow makeKeyAndVisible] + 35
    25  UIKit                               0x00335be6 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1820
    26  UIKit                               0x003368a6 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 508
    27  UIKit                               0x00345743 -[UIApplication handleEvent:withNewEvent:] + 1027
    28  UIKit                               0x003461f8 -[UIApplication sendEvent:] + 68
    29  UIKit                               0x00339aa9 _UIApplicationHandleEvent + 8196
    30  GraphicsServices                    0x02398fa9 PurpleEventCallback + 1274
    31  CoreFoundation                      0x0153a1c5 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
    32  CoreFoundation                      0x0149f022 __CFRunLoopDoSource1 + 146
    33  CoreFoundation                      0x0149d90a __CFRunLoopRun + 2218
    34  CoreFoundation                      0x0149cdb4 CFRunLoopRunSpecific + 212
    35  CoreFoundation                      0x0149cccb CFRunLoopRunInMode + 123
    36  UIKit                               0x003362a7 -[UIApplication _run] + 576
    37  UIKit                               0x00337a9b UIApplicationMain + 1175
    38  ParkerAssistant                     0x000024e8 main + 152
    39  ParkerAssistant                     0x00002445 start + 53
)
2012-02-28 23:51:00.726 ParkerAssistant[1454:f803] *** Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer bounds contains NaN: [inf inf; nan nan]'
*** First throw call stack:
(0x1566052 0x1b1ad0a 0x150ea78 0x150e9e9 0x1df137 0x1d52fa 0x3ee9a 0x2f55 0x3fd64e 0x418b89 0x4189bd 0x416f8a 0x416e2f 0x414ffb 0x41585a 0x3fefbf 0x3ff21b 0x4000f1 0x36efec 0x374572 0x36e72b 0x35dbc2 0x35dce2 0x35dea8 0x364d9a 0x335be6 0x3368a6 0x345743 0x3461f8 0x339aa9 0x2398fa9 0x153a1c5 0x149f022 0x149d90a 0x149cdb4 0x149cccb 0x3362a7 0x337a9b 0x24e8 0x2445)
terminate called throwing an exception
编辑3:viewDidLoad方法:

看起来,选项卡式视图控制器与编辑Hi无关。 我为一个新的单视图应用程序再次复制了它,但它不再工作了。 我应该提到的是,在工作应用程序不使用故事板,只使用一个xib文件之前,我认为这没有任何区别。2个不工作选项卡和单个视图不工作 我甚至不知道从哪里开始。。
谢谢

您是否链接了QuartzCore.framework?我很确定CALayer需要夸脱矿。您可以通过选择目标->构建阶段选项卡-将二进制文件链接到库来实现这一点。单击加号,向下滚动到底部,选择QuartzCore将其链接到您的项目

在-[ParkerAsistantFirstViewController viewDidLoad]方法中,您将重新计算消息发送到RMPath的实例。然后,RMPath设置CALayer的边界

查看异常消息,我们可以看到RMPath正在将层的边界设置为矩形[inf;nan]。inf是“infinity”的缩写,因此矩形的原点是无穷大。nan这个词的意思是“不是数字”,所以矩形的大小是完全无效的。这就是卡莱尔所抱怨的


查看第一次编辑中的变量,我看到比例为0。这是可疑的。如果这是视图的缩放因子,那么它可能无效。如果这是您可以控制的,请尝试将其设置为1或其他小正数。

问题在于我没有将地图输出mapView链接到情节提要中的RMMapView对象。现在它开始工作。

,然后编辑您的问题并粘贴到exception.Edited的堆栈跟踪中。希望这就是你的意思。你的第二次编辑就是我的意思。谢谢你的关注。我没有称为scale的变量。可能是来自RMPath对象。此外,RMPath.h没有说明方法u。。。我将用viewDidLoad方法编辑这篇文章。它似乎与故事板有关。。查看我的编辑plz!谢谢
- (void)viewDidLoad {
    [super viewDidLoad];
    locationManager = [[CLLocationManager alloc] init];
    locationManager.distanceFilter = kCLDistanceFilterNone;
    locationManager.desiredAccuracy = kCLLocationAccuracyBest;
    locationManager.delegate = self;
    [locationManager startUpdatingLocation];

    id cmTilesource = [[RMCloudMadeMapSource alloc] initWithAccessKey:@"dfd3baf1ceda40ff8b4bf4b55303253d" styleNumber:1];
    [[RMMapContents alloc] initWithView:mapView tilesource: cmTilesource];
    tokenManager = [[TokenManager alloc] initWithApikey:@"dfd3baf1ceda40ff8b4bf4b55303253d"];
    _routingManager = [[CMRoutingManager alloc] initWithMapView:mapView tokenManager:tokenManager];

    _routingManager.delegate = self;

    int width = self.view.frame.size.width;
    int height = 64;
    _rifRect = CGRectMake(0, 0, width, height);
    _firCenter = CGPointMake(width/2,height/2);

    route = [[RMPath alloc] initForMap:mapView];

    route.lineColor = [UIColor blueColor];
    route.fillColor = [UIColor clearColor];
    route.lineWidth = 5;
    route.scaleLineWidth = NO;

    _rif = [[CMRouteInfoView alloc] init:_rifRect :nil];
    _rif.center = _firCenter;
    _rif.autoresizingMask = UIViewAutoresizingFlexibleWidth;

    _rif.delegate = self;
}