ios - 强制模拟位置在 XCode 6.4 中固定

标签 ios xcode swift core-location

您好,我正在尝试使用此功能通过我的应用模拟我的 iOS 模拟器的位置。

Simulate location

应用程序像这样获取位置

var currentLocation: CLLocation?
if (CLLocationManager.authorizationStatus() == CLAuthorizationStatus.AuthorizedWhenInUse || CLLocationManager.authorizationStatus() == CLAuthorizationStatus.AuthorizedAlways) {
    currentLocation = manager.location
}

问题是这段代码是在应用程序启动时执行的,然后模拟位置总是重置为空。我可以在通过 XCode 再次启动应用程序后强制将此位置设置为相同的值吗?

最佳答案

您可以编辑应用程序的方案,转到运行阶段,单击选项选项卡,然后选中复选框,允许位置模拟。然后您可以选择默认的模拟位置。

enter image description here

附带说明一下,您可以将 GPX 文件添加到您的项目中以用于自定义模拟位置,例如您的办公室、家或最喜欢的吃饭的地方,这些也可以选择作为模拟位置。

关于ios - 强制模拟位置在 XCode 6.4 中固定,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31971646/

相关文章:

ios - 验证应用程序

ios - 如何在 Instruments Time Profiler 中显示调用函数的次数

iphone - 在 Storyboard 中实现一个 AlertBox

ios - NSOperation 获取图像并更新 UITableView UIImageView 属性

iphone - 使用 AVAudioRecorder 录制 WAV 格式文件?

arrays - Swift:数组、文本字段和 UITableView

ios - 如何修复导航 Controller 中的 UIButtons 越界问题?

ios - 在 View Controller 之间传递数据

ios - 多选模式下的 UITableView 删除所选单元格中所有 subview 的背景颜色

ios - 导航 Controller 工具栏按钮问题 - Xcode