菜鸟教程小白 发表于 2022-12-13 02:12:09

c++ - 从后台进入后iOS Vuforia错误


                                            <p><p>我在我的 iOS 应用程序中使用 Vuforia SDK,版本 6.2.9。
一切正常,但应用从后台进入时出现错误。</p>

<p>运行 VUFORIA 的 ViewController 正在监听 <strong>UIApplicationWillResignActiveNotification</strong> 和 <strong>UIApplicationDidBecomeActiveNotification</strong> 通知。
在 UIApplicationWillResignActiveNotification 暂停 AR 的情况下,在 UIApplicationDidBecomeActiveNotification 的情况下恢复 AR。</p>

<pre><code>// we use the iOS notification to pause/resume the AR when the application goes (or come back from) background

[
addObserver:self
selector:@selector(pauseAR)
name:UIApplicationWillResignActiveNotification
object:nil];

[
addObserver:self
selector:@selector(resumeAR)
name:UIApplicationDidBecomeActiveNotification
object:nil];
</code></pre>

<p>这些是方法</p>

<pre><code>- (void) pauseAR {
   NSError * error = nil;
   if (!) {
      NSLog(@&#34;Error pausing AR:%@&#34;, );
   }
}

- (void) resumeAR {

    NSError * error = nil;
    if(! ) {
      NSLog(@&#34;Error resuming AR:%@&#34;, );
    }

    // on resume, we reset the flash
    Vuforia::CameraDevice::getInstance().setFlashTorchMode(false);

    ;
}
</code></pre>

<p>当我返回扫描模式时,应用程序从后台进入后,相机被卡住,出现错误
<strong>找不到响应选择器 renderFrameVuforia 的带有 CAEAGLLayer 或 CAMetalLayer 层类的 UIView</strong></p>

<pre><code>2017-07-17 11:13:01.187406+0200 App frame: {{0, 0}, {375, 667}}
2017-07-17 11:13:01.243707+0200 App DEBUG/AR(8689) Could not find a UIView with CAEAGLLayer or CAMetalLayer layer class that responds to selector renderFrameVuforia
2017-07-17 11:13:01.253958+0200 App Vuforia Library version 6.2.9
2017-07-17 11:13:01.731099+0200 App AR View: Rotating to Portrait
2017-07-17 11:13:01.731406+0200 App frame: {{0, 0}, {375, 667}}
2017-07-17 11:13:01.731562+0200 App VideoBackgroundConfig: size: 750,1334
2017-07-17 11:13:01.731589+0200 App VideoMode:w=1280 h=720
2017-07-17 11:13:01.731611+0200 App width=750.000 height=1334.000
2017-07-17 11:13:01.731638+0200 App ViewPort: X,Y: 0,0 Size X,Y:750,1334
2017-07-17 11:13:02.598959+0200 App INFO/AR(8689) 2017-07-18 11:13:02: Completed CloudReco transaction with ID &#39;6f5c61ecc07741a7b652242abf909479&#39;
2017-07-17 11:13:02.843834+0200 App frame: {{0, 0}, {375, 667}}
2017-07-17 11:13:02.844215+0200 App frame: {{0, 0}, {375, 667}}
2017-07-17 11:13:02.860971+0200 App DEBUG/AR(8689) UIView has CAEAGLLayer layer class
2017-07-17 11:13:02.861114+0200 App DEBUG/AR(8689) UIView does not respond to selector renderFrameVuforia
2017-07-17 11:13:02.861191+0200 App DEBUG/AR(8689) UIView has CAEAGLLayer layer class
2017-07-17 11:13:02.861222+0200 App DEBUG/AR(8689) UIView does not respond to selector renderFrameVuforia
</code></pre>

<p>感谢您的帮助!</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>你在哪个方法中调用 <code>pauseAR()</code> ?</p>

<p>当我回到 ViewController(拥有 EAGLView)时,我遇到了同样的问题,相机被卡住了。 </p>

<p>我在 <code>viewWillDisappear()</code> 中调用 <code>pauseAR()</code> 并在 <code>viewWillAppear()</code> 中调用 <code>resumeAR()</code>,如问题出在 EAGLView 中的委托(delegate)方法 <code>renderFrameVuforia()</code> 从未被调用,我认为这是导致问题的原因:</p>

<blockquote>
<p>Could not find a UIView with CAEAGLLayer or CAMetalLayer layer class that responds to selector renderFrameVuforia</p>
</blockquote>

<p>于是我查阅了 Vuforia 开发者库,发现:</p>

<blockquote>
<p>The app&#39;s view hierarchy is set up completely before calling QCAR::onResume() (at which point QCAR attempts to locate the app&#39;s view conforming to UIGLViewProtocol).</p>
</blockquote>

<p>我将调用位置的<code>resumeAR()</code>方法更改为<code>viewDidAppear()</code>,一切正常。希望对您有所帮助。</p></p>
                                   
                                                <p style="font-size: 20px;">关于c&#43;&#43; - 从后台进入后iOS Vuforia错误,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/45140805/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/45140805/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: c&#43;&#43; - 从后台进入后iOS Vuforia错误