gpt4 book ai didi

iphone - MKMapView 关闭定位服务

转载 作者:塔克拉玛干 更新时间:2023-11-02 10:17:56 26 4
gpt4 key购买 nike

我在我的应用程序中使用带有“showsUserLocation”选项的 MKMapView。我已经使用界面生成器添加了 map View ,并在 viewDidAppear 和 viewWillDissappear 中设置了 showUserLocation 选项。

问题出在从 View 返回或将应用程序置于后台时。位置服务图标不会消失。实际上我必须删除应用程序才能使其消失。即使我手动强制关闭该应用程序,它仍然存在,如果我进入设置,它仍然在使用定位服务的应用程序列表中处于事件状态。

我在下面添加了相关代码,我在这里缺少什么??提前致谢!

*.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];
}

最佳答案

我只是猜测,这可能无法解决问题,但请尝试在两个语句中添加 self

- (void)viewDidAppear:(BOOL)animated {

[super viewDidAppear:animated];

self.theMapView.showsUserLocation = YES;
}

- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];

self.theMapView.showsUserLocation = NO;

}

关于iphone - MKMapView 关闭定位服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8211197/

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