91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

[IOS]地圖的簡單應用

發布時間:2020-05-07 23:59:56 來源:網絡 閱讀:415 作者:蓬萊仙羽 欄目:移動開發

IOSMapKit如何快速入門?下面我來寫一個簡單的Demo,做簡要介紹。

效果圖:

[IOS]地圖的簡單應用

操作步驟:

1.首先創建一個項目,在xib的view中添加一個MapVIew控件,并且導入MapKit.framework和CoreLocation.frameword框架。

2.實現ViewController的代碼:

ViewController.h:

#import <UIKit/UIKit.h> #import <MapKit/MapKit.h> #import <CoreLocation/CoreLocation.h> @interface DXWViewController : UIViewController<CLLocationManagerDelegate> @property (retain, nonatomic) IBOutlet MKMapView *mapview; @property(retain,nonatomic)CLLocationManager *manager; @property(retain,nonatomic)CLLocation *location; @property (retain, nonatomic) IBOutletCollection(UILabel) NSArray *labels; @end 

ViewController.m:

#import "DXWViewController.h" #import "Place.h" @interface DXWViewController ()  @end  @implementation DXWViewController  - (void)viewDidLoad {     [super viewDidLoad];     self.manager  = [[CLLocationManager alloc] init];     self.manager.delegate = self;     //精度     self.manager.desiredAccuracy = kCLLocationAccuracyBest;     [self.manager startUpdatingLocation]; 	self.mapview.showsUserLocation = YES; }   -(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations {     self.location = [locations objectAtIndex:0];     [self.labels[0] setText:[NSString stringWithFormat:@"%f\u00B0",self.location.coordinate.longitude]];     [self.labels[1] setText:[NSString stringWithFormat:@"%f\u00B0",self.location.coordinate.longitude]];     [self.labels[2] setText:[NSString stringWithFormat:@"%gm",self.location.horizontalAccuracy]];     [self.labels[3] setText:[NSString stringWithFormat:@"%gm",self.location.altitude]];     [self.labels[4] setText:[NSString stringWithFormat:@"%gm",self.location.verticalAccuracy]];          Place *place = [[Place alloc] init];     place.coordinate = self.location.coordinate;     place.title = @"Title";     place.subtitle = @"subTitle";          [self.mapview addAnnotation:place];     //設置精度范圍     MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(place.coordinate, 1000, 1000);     [self.mapview setRegion:region animated:YES]; } - (void)didReceiveMemoryWarning {     [super didReceiveMemoryWarning]; }  - (void)dealloc {     [_mapview release];     [_labels release];     [super dealloc]; } @end

3.創建大頭針的類:

Place.h:

#import <Foundation/Foundation.h> #import <MapKit/MapKit.h> @interface Place : NSObject<MKAnnotation>  @property(copy,nonatomic)NSString *title; @property(copy,nonatomic)NSString *subtitle; @property(assign,nonatomic)CLLocationCoordinate2D coordinate;  @end


向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

登封市| 灯塔市| 贡觉县| 玛多县| 剑河县| 阳东县| 如东县| 泽库县| 梁平县| 通榆县| 桦南县| 南江县| 贵德县| 通辽市| 新丰县| 香格里拉县| 玉环县| 綦江县| 三原县| 合水县| 乌鲁木齐市| 荆州市| 瑞安市| 华蓥市| 麻城市| 桐庐县| 彰化县| 漠河县| 康马县| 六安市| 黑山县| 乌拉特后旗| 龙江县| 黔江区| 新安县| 乌兰县| 江北区| 凌海市| 邛崃市| 南城县| 喀喇沁旗|