Qt Positioning 在 iOS 上
在 iOS 应用中使用Qt Positioning 服务
要使应用能够在 iOS 设备上使用定位服务,必须根据应用是在使用中还是在后台运行时需要定位服务,在 Info.plist 文件中添加相应条目。
添加权限后,当应用请求定位服务时,用户需要授予该权限才能使用定位服务。用户可通过进入“设置” > “隐私” > “定位服务”,向下滚动找到该应用,然后选择相应选项来更改此设置。定位服务必须处于开启状态才能正常工作。
使用前台位置服务权限
如果应用在运行时使用定位服务,Info.plist 文件中必须包含一个键为NSLocationWhenInUseUsageDescription 的条目,其值应为一个文本字符串,向用户说明应用使用该服务的理由。
<key>NSLocationWhenInUseUsageDescription</key>
<string>The reason why the app needs location services</string>使用后台定位服务权限
如果应用在后台运行时仍使用定位服务,则需要包含一个键为NSLocationAlwaysAndWhenInUseUsageDescription 、值为说明字符串的条目,以及键为NSLocationWhenInUseUsageDescription 的条目。
<key>NSLocationWhenInUseUsageDescription</key>
<string>The reason why the app needs location services</string>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>The reason why the app needs location services</string>注意: Info.plist文件 是自动生成的,除非采取相应措施,否则所做的更改可能会被 qmake 或 CMake 覆盖。更多信息请参阅《平台说明 - iOS》。
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.