我在我的應用程序中使用帶有「showsUserLocation」選項的MKMapView。我已經使用界面構建器添加了mapview,並在viewDidAppear和viewWillDissappear中設置了showUserLocation選項。MKMapView關閉位置服務
問題是從視圖返回或將應用程序置於後臺時。位置服務圖標不會消失。其實我必須刪除應用程序才能使其消失。即使我手動強制關閉應用程序,它仍然存在,如果我進入設置,它仍然在使用位置服務的應用程序列表中處於活動狀態。
我在下面添加了相關的代碼,我在這裏丟失了什麼?提前致謝!
的* .h:
#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
@interface ***viewController: UIViewController {
IBOutlet MKMapView *theMapView;
}
@property (nonatomic, retain) MKMapView *theMapView;
@end
* .M
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
theMapView.showsUserLocation = YES;
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
theMapView.showsUserLocation = NO;
}
- (void)dealloc {
[super dealloc];
[theMapView release];
}
添加委託的.h類並添加自己。 theMapView.delegate = self; –
將代表添加到mapView沒有幫助,但感謝回覆。 – Madoc
你是否設法解決這個問題?如果是這樣,我很想知道解決方案。 – chakrit