iOS 从后台进入后Vuforia错误
iOS Vuforia error after entering from background
我在 iOS 应用程序中使用 Vuforia SDK,版本 6.2.9。
一切正常,但应用程序从后台进入时出现错误。
viewcontroller 运行 VUFORIA 正在侦听 UIApplicationWillResignActiveNotification 和 UIApplicationDidBecomeActiveNotification 通知。
在 UIApplicationWillResignActiveNotification 情况下暂停 AR,在 UIApplicationDidBecomeActiveNotification 情况下恢复 AR.
// we use the iOS notification to pause/resume the AR when the application goes (or come back from) background
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(pauseAR)
name:UIApplicationWillResignActiveNotification
object:nil];
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(resumeAR)
name:UIApplicationDidBecomeActiveNotification
object:nil];
这些是方法
- (void) pauseAR {
NSError * error = nil;
if (![vapp pauseAR:&error]) {
NSLog(@"Error pausing AR:%@", [error description]);
}
}
- (void) resumeAR {
NSError * error = nil;
if(! [vapp resumeAR:&error]) {
NSLog(@"Error resuming AR:%@", [error description]);
}
// on resume, we reset the flash
Vuforia::CameraDevice::getInstance().setFlashTorchMode(false);
[self handleRotation:self.interfaceOrientation];
}
当我return进入扫描模式时,应用程序从后台进入后,相机冻结,报错
无法找到具有响应选择器 renderFrameVuforia
的 CAEAGLLayer 或 CAMetalLayer 层 class 的 UIView
2017-07-17 11:13:01.187406+0200 App[8689:2961061] frame: {{0, 0}, {375, 667}}
2017-07-17 11:13:01.243707+0200 App[8689:2961061] 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[8689:2961061] Vuforia Library version 6.2.9
2017-07-17 11:13:01.731099+0200 App[8689:2961061] AR View: Rotating to Portrait
2017-07-17 11:13:01.731406+0200 App[8689:2961061] frame: {{0, 0}, {375, 667}}
2017-07-17 11:13:01.731562+0200 App[8689:2961061] VideoBackgroundConfig: size: 750,1334
2017-07-17 11:13:01.731589+0200 App[8689:2961061] VideoMode:w=1280 h=720
2017-07-17 11:13:01.731611+0200 App[8689:2961061] width=750.000 height=1334.000
2017-07-17 11:13:01.731638+0200 App[8689:2961061] ViewPort: X,Y: 0,0 Size X,Y:750,1334
2017-07-17 11:13:02.598959+0200 App[8689:2962160] INFO/AR(8689) 2017-07-18 11:13:02: Completed CloudReco transaction with ID '6f5c61ecc07741a7b652242abf909479'
2017-07-17 11:13:02.843834+0200 App[8689:2961061] frame: {{0, 0}, {375, 667}}
2017-07-17 11:13:02.844215+0200 App[8689:2961061] frame: {{0, 0}, {375, 667}}
2017-07-17 11:13:02.860971+0200 App[8689:2961061] DEBUG/AR(8689) UIView has CAEAGLLayer layer class
2017-07-17 11:13:02.861114+0200 App[8689:2961061] DEBUG/AR(8689) UIView does not respond to selector renderFrameVuforia
2017-07-17 11:13:02.861191+0200 App[8689:2961061] DEBUG/AR(8689) UIView has CAEAGLLayer layer class
2017-07-17 11:13:02.861222+0200 App[8689:2961061] DEBUG/AR(8689) UIView does not respond to selector renderFrameVuforia
感谢您的帮助!
你在哪个方法中调用了pauseAR()
?
当我跳回 ViewController(拥有 EAGLView)时,我遇到了同样的问题,相机被冻结了。
我在 viewWillDisappear()
中调用 pauseAR()
并在 viewWillAppear()
中调用 resumeAR()
,因为问题出现了,EAGLView 中的委托方法 renderFrameVuforia()
从未被调用,我认为这是问题原因:
Could not find a UIView with CAEAGLLayer or CAMetalLayer layer class that responds to selector renderFrameVuforia
所以我查阅了 Vuforia 开发者库并发现:
The app's view hierarchy is set up completely before calling QCAR::onResume() (at which point QCAR attempts to locate the app's view conforming to UIGLViewProtocol).
我将名为 position 的 resumeAR()
方法更改为 viewDidAppear()
,一切正常。希望对您有所帮助。
我在 iOS 应用程序中使用 Vuforia SDK,版本 6.2.9。 一切正常,但应用程序从后台进入时出现错误。
viewcontroller 运行 VUFORIA 正在侦听 UIApplicationWillResignActiveNotification 和 UIApplicationDidBecomeActiveNotification 通知。 在 UIApplicationWillResignActiveNotification 情况下暂停 AR,在 UIApplicationDidBecomeActiveNotification 情况下恢复 AR.
// we use the iOS notification to pause/resume the AR when the application goes (or come back from) background
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(pauseAR)
name:UIApplicationWillResignActiveNotification
object:nil];
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(resumeAR)
name:UIApplicationDidBecomeActiveNotification
object:nil];
这些是方法
- (void) pauseAR {
NSError * error = nil;
if (![vapp pauseAR:&error]) {
NSLog(@"Error pausing AR:%@", [error description]);
}
}
- (void) resumeAR {
NSError * error = nil;
if(! [vapp resumeAR:&error]) {
NSLog(@"Error resuming AR:%@", [error description]);
}
// on resume, we reset the flash
Vuforia::CameraDevice::getInstance().setFlashTorchMode(false);
[self handleRotation:self.interfaceOrientation];
}
当我return进入扫描模式时,应用程序从后台进入后,相机冻结,报错 无法找到具有响应选择器 renderFrameVuforia
的 CAEAGLLayer 或 CAMetalLayer 层 class 的 UIView2017-07-17 11:13:01.187406+0200 App[8689:2961061] frame: {{0, 0}, {375, 667}}
2017-07-17 11:13:01.243707+0200 App[8689:2961061] 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[8689:2961061] Vuforia Library version 6.2.9
2017-07-17 11:13:01.731099+0200 App[8689:2961061] AR View: Rotating to Portrait
2017-07-17 11:13:01.731406+0200 App[8689:2961061] frame: {{0, 0}, {375, 667}}
2017-07-17 11:13:01.731562+0200 App[8689:2961061] VideoBackgroundConfig: size: 750,1334
2017-07-17 11:13:01.731589+0200 App[8689:2961061] VideoMode:w=1280 h=720
2017-07-17 11:13:01.731611+0200 App[8689:2961061] width=750.000 height=1334.000
2017-07-17 11:13:01.731638+0200 App[8689:2961061] ViewPort: X,Y: 0,0 Size X,Y:750,1334
2017-07-17 11:13:02.598959+0200 App[8689:2962160] INFO/AR(8689) 2017-07-18 11:13:02: Completed CloudReco transaction with ID '6f5c61ecc07741a7b652242abf909479'
2017-07-17 11:13:02.843834+0200 App[8689:2961061] frame: {{0, 0}, {375, 667}}
2017-07-17 11:13:02.844215+0200 App[8689:2961061] frame: {{0, 0}, {375, 667}}
2017-07-17 11:13:02.860971+0200 App[8689:2961061] DEBUG/AR(8689) UIView has CAEAGLLayer layer class
2017-07-17 11:13:02.861114+0200 App[8689:2961061] DEBUG/AR(8689) UIView does not respond to selector renderFrameVuforia
2017-07-17 11:13:02.861191+0200 App[8689:2961061] DEBUG/AR(8689) UIView has CAEAGLLayer layer class
2017-07-17 11:13:02.861222+0200 App[8689:2961061] DEBUG/AR(8689) UIView does not respond to selector renderFrameVuforia
感谢您的帮助!
你在哪个方法中调用了pauseAR()
?
当我跳回 ViewController(拥有 EAGLView)时,我遇到了同样的问题,相机被冻结了。
我在 viewWillDisappear()
中调用 pauseAR()
并在 viewWillAppear()
中调用 resumeAR()
,因为问题出现了,EAGLView 中的委托方法 renderFrameVuforia()
从未被调用,我认为这是问题原因:
Could not find a UIView with CAEAGLLayer or CAMetalLayer layer class that responds to selector renderFrameVuforia
所以我查阅了 Vuforia 开发者库并发现:
The app's view hierarchy is set up completely before calling QCAR::onResume() (at which point QCAR attempts to locate the app's view conforming to UIGLViewProtocol).
我将名为 position 的 resumeAR()
方法更改为 viewDidAppear()
,一切正常。希望对您有所帮助。