菜鸟教程小白 发表于 2022-12-11 19:15:08

ios - NSCameraUsageDescription 不起作用


                                            <p><p>我正在尝试打开用户的相机,但每当我尝试打开相机时,我都会收到此错误消息,“该应用程序已崩溃,因为它试图在没有使用说明的情况下访问隐私敏感数据。该应用程序的 Info.plist必须包含一个带有字符串值的 NSCameraUsageDescription 键,向用户解释应用程序如何使用这些数据。”我已经在 info.plist 文件中添加了隐私 - 相机使用说明以及诸如“我需要使用您的相机”之类的值,但我仍然收到此错误。
这是我的 info.plist 源代码</p>

<pre><code>&lt;?xml version=&#34;1.0&#34; encoding=&#34;UTF-8&#34;?&gt;
&lt;!DOCTYPE plist PUBLIC &#34;-//Apple//DTD PLIST 1.0//EN&#34; &#34;http://www.apple.com/DTDs/PropertyList-1.0.dtd&#34;&gt;
&lt;plist version=&#34;1.0&#34;&gt;
&lt;dict&gt;
    &lt;key&gt;CFBundleDevelopmentRegion&lt;/key&gt;
    &lt;string&gt;en&lt;/string&gt;
    &lt;key&gt;CFBundleExecutable&lt;/key&gt;
    &lt;string&gt;$(EXECUTABLE_NAME)&lt;/string&gt;
    &lt;key&gt;CFBundleIdentifier&lt;/key&gt;
    &lt;string&gt;$(PRODUCT_BUNDLE_IDENTIFIER)&lt;/string&gt;
    &lt;key&gt;CFBundleInfoDictionaryVersion&lt;/key&gt;
    &lt;string&gt;6.0&lt;/string&gt;
    &lt;key&gt;CFBundleName&lt;/key&gt;
    &lt;string&gt;$(PRODUCT_NAME)&lt;/string&gt;
    &lt;key&gt;CFBundlePackageType&lt;/key&gt;
    &lt;string&gt;APPL&lt;/string&gt;
    &lt;key&gt;CFBundleShortVersionString&lt;/key&gt;
    &lt;string&gt;1.0&lt;/string&gt;
    &lt;key&gt;CFBundleVersion&lt;/key&gt;
    &lt;string&gt;1&lt;/string&gt;
    &lt;key&gt;LSRequiresIPhoneOS&lt;/key&gt;
    &lt;true/&gt;
    &lt;key&gt;NSLocationWhenInUseUsageDescription&lt;/key&gt;
    &lt;string&gt;Needed to receive your current location.&lt;/string&gt;
    &lt;key&gt;NSCameraUsageDescription&lt;/key&gt;
    &lt;string&gt;Need to use camera for AR&lt;/string&gt;
    &lt;key&gt;UILaunchStoryboardName&lt;/key&gt;
    &lt;string&gt;LaunchScreen&lt;/string&gt;
    &lt;key&gt;UIMainStoryboardFile&lt;/key&gt;
    &lt;string&gt;Main&lt;/string&gt;
    &lt;key&gt;NSAppTransportSecurity&lt;/key&gt;
    &lt;dict&gt;
      &lt;key&gt;NSAllowsArbitraryLoads&lt;/key&gt;
      &lt;true/&gt;
    &lt;/dict&gt;
    &lt;key&gt;UIRequiredDeviceCapabilities&lt;/key&gt;
    &lt;array&gt;
      &lt;string&gt;armv7&lt;/string&gt;
    &lt;/array&gt;
    &lt;key&gt;UISupportedInterfaceOrientations&lt;/key&gt;
    &lt;array&gt;
      &lt;string&gt;UIInterfaceOrientationPortrait&lt;/string&gt;
      &lt;string&gt;UIInterfaceOrientationLandscapeLeft&lt;/string&gt;
      &lt;string&gt;UIInterfaceOrientationLandscapeRight&lt;/string&gt;
    &lt;/array&gt;
&lt;/dict&gt;
&lt;/plist&gt;
</code></pre>

<p>***我找到了解决办法。我必须进入“信息”并在自定义 IOS 目标属性中添加隐私 key </p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>奇怪的是,在 iOS 10 之后,您必须定义对所有硬件的访问权限。您很可能会错过“隐私麦克风使用说明”。切换到“管理器”并查看设备上的崩溃报告并添加其中列出的所有隐私错误。</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - NSCameraUsageDescription 不起作用,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/42797763/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/42797763/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - NSCameraUsageDescription 不起作用