iOS Mapkit - SetRegion错误

时间:2012-08-23 06:31:44

标签: ios mkmapview mapkit

你能指出我这个代码有什么问题吗?

-(void) showStoreRegion:(NSInteger)idx
{

    //StoreLocation* store = [self.listStore objectAtIndex:idx];

    //self.coordinate = CLLocationCoordinate2DMake(store.latitude,store.longitude);

    self.coordinate = CLLocationCoordinate2DMake(10.7500,106.6667);

    MKCoordinateRegion region;
    MKCoordinateSpan span;
    span.latitudeDelta  = 0.001;
    span.longitudeDelta = 0.001;

    region.span = span;
    region.center = self.coordinate;


    [theMapView setRegion:region animated:TRUE];
    [theMapView regionThatFits:region];


    [self addAnns];

} 

我收到此消息“由于未捕获的异常'NSInvalidArgumentException'终止应用,原因:'无效区域' “运行此代码/

1 个答案:

答案 0 :(得分:0)

您尚未初步确定您所在的地区。试试这个

MKCoordinateSpan span = MKCoordinateSpanMake(0.001,0.001);
MKCoordinateRegion region = MKCoordinateRegionMake(self.coordinate, span)