我正在試圖讓Map Kit將當前用戶的位置顯示爲預定義的大小。添加新的授權過程後MapKit崩潰
一切正常,但自從更新到Xcode 6和iOS 8以後,事情就發生了變化。
我已經實施了必要的授權,現在應用程序崩潰。與***
代碼是該系統似乎有問題的代碼。
這裏是Map.m
#import "MRVCMapViewController.h"
#import <MapKit/MapKit.h>
#import <CoreLocation/CoreLocation.h>
@import CoreLocation;
@interface MRVCMapViewController()
@end
@implementation MRVCMapViewController
@synthesize mapView;
- (void)viewDidLoad {
[super viewDidLoad];
//location permission
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self;
if ([self.locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)])
{
[self.locationManager requestWhenInUseAuthorization];
}
[self.locationManager startUpdatingLocation];
//mapview settings
self.mapView.delegate = self;
self.mapView.showsUserLocation = YES;
}
- (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation
{
***MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(userLocation.coordinate, 800, 800);
[self.mapView setRegion:[self.mapView regionThatFits:region] animated:YES];***
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
無論何時說「應用程序崩潰」,都要包含控制檯中顯示的確切崩潰消息。 – Anna 2014-09-22 10:53:07