日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

OC开发_Storyboard——MapKit

發布時間:2023/12/9 编程问答 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 OC开发_Storyboard——MapKit 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

一、Core ?Location

1、基本對象

? ?@propertys: coordinate, altitude, horizontal/verticalAccuracy, timestamp, speed, course?

? ?@property (readonly) CLLocationCoordinate2D coordinate;

? ? ?typedef {

CLLocationDegrees latitude; // ? double型 緯度

CLLocationDegrees longitude; // ?double 型 經度

} CLLocationCoordinate2D;

? ? ? ? ? @property (readonly) CLLocationDistance altitude; ?//高度 (單位:米)

2、精度

kCLLocationAccuracyBestForNavigation ?//精度最好,但同時最耗電,以下類推

kCLLocationAccuracyBest

kCLLocationAccuracyNearestTenMeters

kCLLocationAccuracyHundredMeters

kCLLocationAccuracyKilometer

kCLLocationAccuracyThreeKilometers

3、如何獲得Core Location?[通過CLLocationManager]

通常的步驟是:(1 通過硬件獲得支持 ?(2 創建一個CLLocationManager實例并設置委托 (3 配置如何更新、精度 (4 開啟這個Manager運行

?

4、在最開始創建Location Manager的時候,需要檢查下面這些項:

? ? ? ? ? ? ?+ (CLAuthorizationStatus)authorizationStatus; //*?檢查應用的授權狀態?*應用在第一次啟動時,會自動請求授權,應用應當明確被授權使用位置服務,并且位置服務當前出于運行狀態,應用才能使用位置服務。

? ? ? ? ? ? ?+ (BOOL)locationServicesEnabled; //?* 判斷用戶是否啟動位置服務?* 在啟動位置更新操作之前,用戶應當檢查該方法的返回值來查看設備的位置服務是否啟動。如果位置服務沒有啟動,而用戶又啟動了位置更新操作,那么Core Location 框架將會彈出一個讓用戶確認是否啟動位置服務的對話框。

? ? ? ? ? ? ?+ (BOOL)significantLocationChangeMonitoringAvailable; //*?表明設備能否報告基于significant location changges的更新 *(significant location change監控,只是基于設備所鏈接的蜂窩塔的位置改變診斷,在精度要求不高的情況下,可以節省很多電量。)

? ? ? ? ? ? ?+(BOOL)isMonitoringAvailableForClass:(Class)regionClass;// ?對某些設備 beacon的監聽

? ? ? ? ? ? ?+ (BOOL)isRangingAvailable;//*?返回藍牙信號范圍服務是否可用?*。這是iOS 7新增的方法

? ? ? 5、委托

(1 屬性

? @property CLLocationAccuracy desiredAccuracy; // 精度

? @property CLLocationDistance distanceFilter; // 距離過濾器:超過多遠的距離才開始重新定位

(2 定位

?- (void)startUpdatingLocation; ? //開啟定位
?- (void)stopUpdatingLocation; ? //關閉定位

- (void)startMonitoringSignificantLocationChanges; ? ?//可以在后臺或者前臺都能監視到用戶位置的移動,即使程序沒有啟動

- (void)stopMonitoringSignificantLocationChanges; ?//?

? (3?當你的程序沒有運行或者后臺被啟動的時候,這個方法會被發送

? ? ? ? ?application:didFinishLaunchingWithOptions: ?UIApplicationLaunchOptionsLocationKey

? ? (4 圓形范圍[基于對區域的監控]

? ? ? ? ? ? ? - (void)startMonitoringForRegion:(CLRegion *)region; // CLCircularRegion/CLBeaconRegion

? ? ? ? ? ? ??- (void)stopMonitoringForRegion:(CLRegion *)region;?

? ? ? ? ? ? ?//進入范圍的時候,會發送廣播通知你[這是iOS7 新增的]? ? ? ??

? ? ? ? ? ? ?- (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region;

? ? ? ? ? ? ?- (void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region;

? ? ? ? ? ? - (void)locationManager:(CLLocationManager *)manager monitoringDidFailForRegion:(CLRegion *)region

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?? ? ? ? ? ? ? ? ? ?? ? ? ? ? ? ? ? ? ?? ? ? ? ? ? ? ? ? ?? ? ? ? ? ? ? ? ? ? ? ??withError:(NSError *)error;?

接下就可以講講MapKit:

?

二、MKMapView?

?1、annotations :通過點擊會彈出一個?MKAnnotationView?

? ? ??@property (readonly) NSArray *annotations;?

@protocol ?MKAnnotation <NSObject>

@property ?(readonly) CLLocationCoordinate2D coordinate;//?

@optional

@property ?(readonly) NSString *title; ?//標題

@property ?(readonly) NSString *subtitle;//副標題

@end

typedef {

? ? CLLocationDegrees latitude;

? ? CLLocationDegrees longitude;//經緯度

} CLLocationCoordinate2D;

?

? ?2、MKAnnotationView?

@property id <MKAnnotation> annotation;

@property UIImage *image; ?//可以修改如上圖的大頭針的圖片
@property UIView *leftCalloutAccessoryView; ?//彈出View的修改
@property UIView *rightCalloutAccessoryView;

@property BOOL enabled;

@property CGPoint centerOffset;

@property BOOL draggable;?

(1?[非常像UITableView]創建視圖(不創建會自動創建)

- (MKAnnotationView *)mapView:(MKMapView *)sender?viewForAnnotation:(id <MKAnnotation>)annotation

{

? ? MKAnnotationView *aView = [sender dequeueReusableAnnotationViewWithIdentifier:IDENT];

? ? if (!aView) {

? ? ? ? aView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? reuseIdentifier:IDENT];

? ? ? ? aView.annotation = annotation;

? ? ? ? return aView;

}

? ? ? (2 ?View里面的圖標被輕點事件

- (void)mapView:(MKMapView *)sender ? annotationView:(MKAnnotationView *)aView

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? calloutAccessoryControlTapped:(UIControl *)control;?

? ? ? (3 大頭針被輕點事件

- (void)mapView:(MKMapView *)sender didSelectAnnotationView:(MKAnnotationView *)aView

{

? ? if ([aView.leftCalloutAccessoryView isKindOfClass:[UIImageView class]])

? ? {

? ? ? ? UIImageView *imageView = (UIImageView *)aView.leftCalloutAccessoryView;

? ? ? ? imageView.image = ...;

? ? }

}

? ? ? ? (4 調用攝像頭操作

+ (MKMapCamera *)cameraLookingAtCenterCoordinate:(CLLocationCoordinate2D)coord

?? ? ? ? ? ? ? ? ? ? ? ? ? ? ? fromEyeCoordinate:(CLLocationCoordinate2D)cameraPosition

?? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? eyeAltitude:(CLLocationDistance)eyeAltitude;

? ? ? ? (5 ?設置動畫效果:比如地理位置的轉移,先從上的轉移,然后再從上到下

? ? ?   - (void)mapView:(MKMapView *)mapView didChangeRegionAnimated:(BOOL)animated;

? ?3、MKLocalSearch 搜索

? ? (1 搜索

MKLocalSearchRequest *request = [[MKLocalSearchRequest alloc] init];

request.naturalLanguageQuery = @“Ike’s”;

request.region = ...;

MKLocalSearch *search = [[MKLocalSearch alloc] initWithRequest:request];

[search startWithCompletionHandler:^(MKLocalSearchResponse *response, NSError *error) { ?// 得到一個MKMapItem 數組,里面還包含MKPlacemark ?}];

? ? ?(2 在地圖APP中打開

? ? ? ? ? ? - (BOOL)openInMapsWithLaunchOptions:(NSDictionary *)options;?

? 4、MKDirections 路線?

? ? ? ? ?

?

?

三、Embed Segue?
? ? ? Container View?

總結

以上是生活随笔為你收集整理的OC开发_Storyboard——MapKit的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。