0
從iOS7移至iOS8時,我的應用程序未顯示警報或當前位置的藍點。我試圖根據我在這裏閱讀的內容更改我的代碼,現在警報正在顯示,但只是瞬間,沒有給出選擇任何內容的機會。不用說藍點也不在那裏。 我的代碼是:當前位置警報和點在iOS8中未顯示
MapName.h
#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
#import <CoreLocation/CoreLocation.h>
@interface MapName : UIViewController <MKMapViewDelegate>
@property (strong, nonatomic) IBOutlet MKMapView *MapName;
@property (nonatomic, retain) CLRegion *region;
@property (nonatomic) BOOL showsUserLocation;
@end
MapName.m
//in the (void)viewDiDLoad section
CLLocationManager *locationManager = [[CLLocationManager alloc]init];
locationManager.delegate = _MapName; //Assigning to 'id<CLLocationManagerDelegate>' from incompatible type 'MKMapView*_strong' warning showing here
[locationManager requestWhenInUseAuthorization];
[locationManager startUpdatingLocation];
CLAuthorizationStatus status = [CLLocationManager authorizationStatus];
if (status == kCLAuthorizationStatusDenied ||
status == kCLAuthorizationStatusAuthorizedWhenInUse) {
//UIApplication -openUrl: UIApplicationOpenSettingsURLString //this is the example shown on WWDC
}
[locationManager requestWhenInUseAuthorization];
[locationManager startMonitoringForRegion:_region];
我添加NSLocationWhenIsUseUsageDescription字符串的消息(這是我在警報見) Info.plist