开发者社区 问答 正文

关于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>'

展开
收起
爵霸 2016-03-26 08:14:53 2649 分享 版权
1 条回答
写回答
取消 提交回答
  • 看起来是[mapView regionThatFits:zoomRegion];引起的问题,删了它 :

    MKCoordinateRegion zoomRegion = MKCoordinateRegionForMapRect(MKMapRectWorld);
       // MKCoordinateRegion adjustedRegion = [self.mapView regionThatFits:zoomRegion];
        [self.mapView setRegion:zoomRegion animated:NO];
    2019-07-17 19:15:02
    赞同 展开评论
问答地址: