xcode iOS模拟器调试时无法获取自定义位置

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20001591/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 04:18:02  来源:igfitidea点击:

iOS simulator cannot get custom location when debugging

iosxcodeios-simulator

提问by amb

After updating to Xcode 5.0.2, it seems that iOS simulator custom location option is not working propertly. When I prompt this

更新到 Xcode 5.0.2 后,iOS 模拟器自定义位置选项似乎无法正常工作。当我提示这个

Custom location in iOS simulator 7.0.3

iOS 模拟器 7.0.3 中的自定义位置

And reopen again the custom location dialog

并再次重新打开自定义位置对话框

Custom location failure in iOS simulator 7.0.3

iOS 模拟器 7.0.3 中的自定义位置失败

I end getting the lat/lon values without decimals. Also, if I prompt a .instead of a comma, some times the dialog replaces the point with a comma, and sometimes deletes the decimal values. I've tried closing the simulator, changing hardware and restarting Xcode with no results.

我最终得到没有小数的纬度/经度值。此外,如果我提示 a.而不是逗号,有时对话框会用逗号替换点,有时会删除十进制值。我尝试关闭模拟器,更改硬件并重新启动 Xcode,但没有结果。

回答by alvaro

There is a bug in the modal "Custom Location" window of iOS Simulator that affects users who have the comma set as the decimal number separator.

iOS 模拟器的模式“自定义位置”窗口中存在一个错误,该错误会影响将逗号设置为十进制数分隔符的用户。

If you type the coordinates with the format XX,XX and you press OK, the numbers after the comma are truncated.

如果您以 XX,XX 格式键入坐标并按 OK,逗号后的数字将被截断。

Try inputing both coordinates with the format XX.XXX ( 2 digits + a point (.) + 3 digits) then press OK, then quit the iOS Simulator. When you launch it again, it'll have the desired location.

尝试以 XX.XXX 格式(2 位数字 + 一个点 (.) + 3 位数字)输入两个坐标,然后按 OK,然后退出 iOS 模拟器。当您再次启动它时,它将具有所需的位置。

If you go to the same "Custom location" windows you are going to visualize the coordinates in format XX,XX, but DO NOT PRESS OK in that windows, just press Cancel, because if you press OK they will be truncated again.

如果您转到相同的“自定义位置”窗口,您将以 XX,XX 格式显示坐标,但不要在该窗口中按 OK,只需按 Cancel,因为如果按 OK,它们将再次被截断。

回答by bs7

You can use this Macro #if (TARGET_IPHONE_SIMULATOR)and manually set a custom location in your code.

您可以使用此宏#if (TARGET_IPHONE_SIMULATOR)并在代码中手动设置自定义位置。

Hope it helps

希望能帮助到你

回答by Bruno Serrano

It seems that the iOS Simulator is accepting only decimals with dot instead of comma. For your language (spanish, I think), the Mac OS put comma in decimal numbers. I had the same problem because my Mac OS is in portuguese, that uses the comma as default for decimal numbers.

似乎 iOS 模拟器只接受带点而不是逗号的小数。对于您的语言(我认为是西班牙语),Mac OS 将逗号放在十进制数中。我遇到了同样的问题,因为我的 Mac OS 是葡萄牙语,它使用逗号作为十进制数的默认值。

To change this setting, go to System Preferences > Language & Region > Advanced...and change the Decimalvalue in the number separators from comma (,) to dot (.) (you can change the currency separators if you want).

要更改此设置,请转到System Preferences > Language & Region > Advanced...并将Decimal数字分隔符中的值从逗号 ( ,).更改为点 ( )(如果需要,您可以更改货币分隔符)。

Than, every time you open the custom location prompt, decimal numbers of lat/lon values will appear with dot instead of comma.

然后,每次打开自定义位置提示时,纬度/经度值的十进制数将显示为点而不是逗号。

I hope it has helped you, I couldn't post images because of my poor reputation.

我希望它对你有帮助,因为我的名声不好,我无法发布图片。

回答by Mohamed Jaleel Nazir

In Xcode,Product -> Scheme -> Edit Scheme... (command + <).

在 Xcode 中,产品 -> 方案 -> 编辑方案...(命令 + <)。

Select Run/Debug from Side Menu, optionstab Select "Allow Location Simulation" and select a default location to none. The default location is the reason for custom location changing.

从侧面菜单中选择运行/调试,选项选项卡选择“允许位置模拟”并选择默认位置为无。默认位置是自定义位置更改的原因。

Set your custom Lat/Long to Simulator...

将您的自定义纬度/经度设置为模拟器...