【发布时间】:2014-08-18 20:25:47
【问题描述】:
我在视图控制器的viewDidLoad 中添加了一个 MKUserTrackingBarButtonItem 实例,如下所示:
MKUserTrackingBarButtonItem *userTrackingButton = [[MKUserTrackingBarButtonItem alloc] initWithMapView:self->mapView];
NSMutableArray *toolbarItems = [[NSMutableArray alloc] initWithArray:[mapToolBar items]];
[toolbarItems insertObject:userTrackingButton atIndex:0];
[mapToolBar setItems:toolbarItems];
定位服务已在“设置”中开启,但未针对该应用开启。当点击 MKUserTrackingBarButtonItem 按钮时,模式对话框询问用户是否允许应用使用当前位置。 When "Don't Allow" is selected, MKUserTrackingBarButtonItem turns into a grey dashed spinning icon and the original compass icon is not restored.
如何恢复按钮在地图应用中的状态?
所需的行为与地图应用程序中的行为相同。
- 确保在“设置”>“隐私”>“定位服务”中开启定位服务。
- 在“设置”>“通用”>“重置”>“重置位置和隐私”中重置位置和隐私。
- 启动地图应用。
- 点击左下角的指南针图标。
- 将出现一个对话框,其中包含“地图”希望使用您的当前位置”消息。此时,指南针图标已变成灰色的虚线旋转图标。
- 选择“不允许”。
恢复原来的指南针图标。
我在 iPhone 上而不是在模拟器上进行测试。上述代码在定位服务开启且允许应用使用当前位置时正常运行。
【问题讨论】:
标签: ios iphone objective-c core-location