It should do this automatically
In the latest Books sample it is using stopAR
- (void)viewWillDisappear:(BOOL)animated {
if (!self.presentedViewController) {
[vapp stopAR:nil];
// Be a good OpenGL ES citizen: now that QCAR is paused and the render
// thread is not executing, inform the root view controller that the
// EAGLView should finish any OpenGL ES commands
[eaglView finishOpenGLESCommands];
}
}
..though for some reason the counterpart call is missing here:
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
// make sure we're oriented/sized properly before reappearing/restarting
[self handleARViewRotation:self.interfaceOrientation];
}
I'll check as to the reason why.
However in your own code you should be able to use QCAR utils versions as this is just a wrapper i.e. something like this:
- (void)viewDidAppear:(BOOL)animated
{
// resume here as in viewWillAppear the view hasn't always been stitched into the hierarchy
// which means QCAR won't find our EAGLView
NSLog(@"ARVC: viewDidAppear");
if (arVisible == NO)
[qUtils resumeAR];
arVisible = YES;
}
- (void)viewDidDisappear:(BOOL)animated
{
NSLog(@"ARVC: viewDidDisappear");
if (arVisible == YES)
[qUtils pauseAR];
// Be a good OpenGL ES citizen: ensure all commands have finished executing
[arView finishOpenGLESCommands];
arVisible = NO;
}
HTH
N
Thanks. I think the reason you don't see it in viewWillAppear:animated is simply because the XIB gets instantiated EVERY time the experience is loaded. For example, if I go into the Cloud Recognition experience, back out, and then go in again... the view controller gets instantiated via initWithNibName each time (see line 53 of SampleAppAboutViewController). This in turn causes the loadView function to be called, which in turn called the SampleApplicationSession initAR:ARViewBoundsSize:orientation] function, and all the way down the chain until the delegate function onInitARDone:initError is called back in SampleApplicationSession, which then calls [SampleApplicationSession startAR].
Sorry if that's not very clear...