Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 如何求解CALayerInvalidGeometry';,原因:';CALayer位置包含NaN:[NaN]?_Objective C_Ios_Xcode4.3_Arcgis - Fatal编程技术网

Objective c 如何求解CALayerInvalidGeometry';,原因:';CALayer位置包含NaN:[NaN]?

Objective c 如何求解CALayerInvalidGeometry';,原因:';CALayer位置包含NaN:[NaN]?,objective-c,ios,xcode4.3,arcgis,Objective C,Ios,Xcode4.3,Arcgis,我有一个错误,它在应用程序启动时崩溃。 这是我得到的错误: *** Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer position contains NaN: [nan nan]' *** First throw call stack: (0x250b022 0x2709cd6 0x24b3a48 0x24b39b9 0x217ec0d 0x2174f55 0x158f3f

我有一个错误,它在应用程序启动时崩溃。 这是我得到的错误:

*** Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer position contains NaN: [nan nan]'
*** First throw call stack:
(0x250b022 0x2709cd6 0x24b3a48 0x24b39b9 0x217ec0d 0x2174f55 0x158f3f7 0xbc74e 0xbe512 0xbfa26 0xbe4ad 0x224ffda 0x224f956 0x224e449 0x224ab9a 0x24df970 0x247f1c1 0x2442967 0x2441d84 0x2441c9b 0x2c0a7d8 0x2c0a88a 0x1559626 0x2aed 0x2a65)
terminate called throwing an exception
我尝试使用异常断点,但它没有显示代码的哪一部分出错。它只在这一点停止-0xbc74e:movl$0,%eax-

我怎样才能解决它?请帮忙

*编辑

我找到了引发异常的部分,但我看不出哪里出了问题

- (void)viewDidLoad {
[super viewDidLoad];
[self.activityView startAnimating];
self.mapView.layerDelegate = self;
self.mapView.touchDelegate = self;
self.mapView.calloutDelegate = self;

NSURL *mapUrl = [NSURL URLWithString:kTiledMapServiceURL];
AGSTiledMapServiceLayer *tiledLyr = [AGSTiledMapServiceLayer tiledMapServiceLayerWithURL:mapUrl];
[self.mapView addMapLayer:tiledLyr withName:@"Tiled Layer"];
        .
        .
        .
}
- (void)mapViewDidLoad:(AGSMapView *)mapView {

AGSEnvelope *envelope = [[AGSEnvelope alloc]initWithXmin:29757.610204117 ymin:40055.0379682464 xmax:29884.6992302249 ymax:40236.6028660071 spatialReference:self.mapView.spatialReference];

//call method to set extent, pass in envelope
[self.mapView zoomToEnvelope:envelope animated:YES];

self.mapView.callout.width = 195.0f;
self.mapView.callout.accessoryButtonHidden = YES;

[self.mapView.gps start];
[self.mapView centerAtPoint:self.mapView.gps.currentPoint animated:YES];  

[self.activityView stopAnimating];
self.activityView.hidden = YES;

}

此行导致错误
self.mapView.layerDelegate=self
默认情况下调用方法
mapViewDidLoad

我认为发生此错误是因为执行的层具有以下形式的帧:

层帧=={inf,inf},{0,0}

这里是下确界。它是一组数字

因此,避免此类问题的解决方案只是在层返回之前创建条件。 例如:

if (layer.frame.size.width ==0 || layer.frame.size.height ==0 ) {
    return [self simpleLayer];
}else{
    return layer;        
} 
其中简单层如下所示:

-(CALayer *)simpleLayer{
    CALayer *layer = [[CALayer alloc] init];
    [layer setFrame:CGRectMake(0, 0, 10, 10)];
    [layer setHidden:TRUE];
    return layer;
}

这种情况解决了我的问题。试试看

我知道这个问题不是最近才提的,但我只想给出一个答案。无论如何,我猜您的
mapView
AGSMapView
的,您已经这样初始化了它:

self.mapView = [[[AGSMapView alloc] init] autorelease];
现在,我认为使用
initWithFrame
初始化它是更好的方法,如果不是唯一正确的方法的话。虽然我不知道为什么,但是如果使用
init
进行初始化,
mapView
会被破坏


希望这能有所帮助。

对我来说,这是因为代码中的toView为零:

    [UIView transitionFromView:self.fromView
                        toView:self.toView
                      duration:0.6
                       options:(currentPage > toPage ? UIViewAnimationOptionTransitionCurlDown : UIViewAnimationOptionTransitionCurlUp)
                    completion:^(BOOL finished) {
                        if (finished) {
                        }
                    }

谢谢你的回答。但我找不到哪一部分出错了。我可以把代码放在哪里?有什么建议吗?