gpt4 book ai didi

ios - 如何在 iOS 中查找当前位置

转载 作者:行者123 更新时间:2023-11-29 03:17:39 24 4
gpt4 key购买 nike

现在我在模拟器中找到我当前的位置

当按下按钮时显示我的当前位置但我的应用位于其他位置

.h

#import <MapKit/MapKit.h>
#import <UIKit/UIKit.h>
#import <CoreLocation/CoreLocation.h>

@interface ViewController : UIViewController<CLLocationManagerDelegate>

@property (nonatomic,retain)MKMapView *mapView;
- (IBAction)myview:(id)sender;
@property (strong, nonatomic) IBOutlet CLLocationManager *locationManger;

@end

.m

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

- (IBAction)myview:(id)sender {
_locationManger =[[CLLocationManager alloc]init];
_locationManger.distanceFilter=kCLDistanceFilterNone;
_locationManger.desiredAccuracy=kCLLocationAccuracyHundredMeters;
[_locationManger startUpdatingLocation];

[_mapView setMapType:MKMapTypeStandard];
[_mapView setZoomEnabled:YES];
[_mapView setScrollEnabled:YES];

MKCoordinateRegion region={ {0.0,0.0 },{0.0,0.0}};

region.center.latitude=_locationManger.location.coordinate.latitude;
region.center.longitude=_locationManger.location.coordinate.longitude;
region.span.longitudeDelta=0.007f;

region.span.latitudeDelta=0.007f;

[_mapView setRegion:region animated:YES];
[_mapView setDelegate:sender];



}
@end

我想在按下按钮时在 map 上显示我当前的位置

最佳答案

使用以下链接非常希望您找到当前位置等,链接是http://www.appcoda.com/how-to-get-current-location-iphone-user/

关于ios - 如何在 iOS 中查找当前位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21495021/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com