【发布时间】:2014-11-14 05:14:07
【问题描述】:
从 iOS7 移动到 iOS8,我的应用没有显示当前位置的警报或蓝点。我试图根据我在这里阅读的内容更改我的代码,现在警报正在显示,但只是一瞬间,没有机会选择任何东西。不用说,蓝点也不存在。 我的代码是:
地图名称.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
地图名称.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
【问题讨论】:
标签: ios8 alert core-location cllocationmanager xcode6