如何在地图Xcode iOS 8上获取当前位置?

时间:2015-02-15 18:54:43

标签: objective-c xcode ios8

我正在尝试在iOS 8上实现Xcode地图,我跟着geekylemon教程 https://www.youtube.com/watch?v=Fr940DT1Z7Y

我认为他是在老版SDK上做的。是否有任何视频教程或github代码在iOS 8上使用故事板和地图视图执行此操作?

我用本教程编写的类是: 的 ViewController.h

#import <MapKit/MapKit.h>
@interface ViewController :UIViewController {
MKMapView *mapview;
}
@property (nonatomic, retain) IBOutlet MKMapView *mapview;
@end

ViewController.m

@implementation ViewController
@synthesize mapview;
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
   MKCoordinateRegion region = { {0.0, 0.0}, {0.0,0.0}};
   region.center.latitude = 40.707184;
   region.center.longitude = -73.998392;
   region.span.longitudeDelta = 0.01f;
   region.span.latitudeDelta = 0.01f;
   [mapview setRegion:region animated:YES];
 }

-(IBAction)GetLocation:(id)sender {
mapview.showsUserLocation = YES;
}

@end

0 个答案:

没有答案