使用mapview找到我的位置 - iOS 8

时间:2014-10-29 18:21:29

标签: ios objective-c iphone map mkmapview

我正在尝试制作一个可以找到当前位置并放大的按钮。我确实尝试了该程序并显示错误。这是程序。

viewController.m

@interface ViewController : UIViewController {

IBOutlet MKMapView *mapview;
}

-(IBAction)findmylocation:(id)sender;

viewController.m

@implementation ViewController

-(IBAction)findmylocation:(id)sender {

mapview.showsUserLocation = YES;
mapview.delegate = self;  <-------[WARNING]
[mapview setUserTrackingMode:MKUserTrackingModeFollow animated:YES];

}

警告错误显示在&#34; mapview.delegate = self;&#34;当我运行应用程序时,我无法点击按钮找到我自己。如果我点击它会说

.... Application Trying to start MapKit location updates without prompting for location authorization. 
Must call -[CLLocationManager requestWhenInUseAuthorization] or -[CLLocationManager requestAlwaysAuthorization] first.

这是警告在&#34; mapview.delegate = self;&#34;行

Assigning to 'id<MKMapViewDelegate>' from incompatible type 'ViewController *const_strong'

我不知道出了什么问题?

0 个答案:

没有答案