更新时间:2023-10-20 23:37:04
检查 -timezone
-NSDateFormatter
的属性 - 我认为这是由设备本身控制的(或在这种情况下您的计算机),而不是位置.设置应用程序中有一个设置,可让您按位置设置时间,我不确定这是否会改变任何内容,但请尝试激活它.
Chech the - timezone
-attribute of the NSDateFormatter
- I think this is controlled by the device itself (or your computer in this case), not the location. There is a setting in the settings-app however that lets you set the time by location, I'm not sure if that would change anything, but try activating that.
一般提示:始终在设备上进行测试 - 我认为模拟位置"设置也适用于手机.
And a general tips: always test it on a device as well - I think the "Simulate Location"-setting works on the phone as well.
刚刚看到一个可能相关的答案,尝试在设置新位置后调用 [NSTimeZone resetTimeZone];
.这应该会触发重置并希望显示正确的时区.参考:https://***.com/a/5987409/267892
Just saw an answer that could be relevant, try calling [NSTimeZone resetTimeZone];
after setting a new location. That should trigger a reset and hopefully display the correct timezone. Ref: https://***.com/a/5987409/267892