2 mapmapm MapMapM 于 2013.01.31 10:46 提问

MKCoordinateRegion setRegion 问题

在ios5.0中下面的代码运行正确:

self.mapView = [[[MKMapView alloc]init] autorelease];
mapView.delegate = self;
mapView.frame = CGRectMake(0, 0, 320, 414);
[myView addSubview:mapView];
MKCoordinateRegion zoomRegion = MKCoordinateRegionForMapRect(MKMapRectWorld);
MKCoordinateRegion adjustedRegion = [mapView regionThatFits:zoomRegion];
[mapView setRegion:adjustedRegion animated:NO];

然后我在iphone6.0中运行,就会在[mapView setRegion:adjustedRegion animated:NO];这个地方崩溃。

    *** Terminating app due to uncaught exception 'NSInvalidArgumentException',
 reason: 'Invalid Region <center:+0.00000000, +0.00000000 span:+176.06470039, +360.00004292>'

应该怎么办呢?谢谢。

1个回答

Mr_me
Mr_me   2013.01.31 11:22
已采纳

看起来是[mapView regionThatFits:zoomRegion];引起的问题,删了它 :

MKCoordinateRegion zoomRegion = MKCoordinateRegionForMapRect(MKMapRectWorld);
   // MKCoordinateRegion adjustedRegion = [self.mapView regionThatFits:zoomRegion];
    [self.mapView setRegion:zoomRegion animated:NO];
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!