Note that there are some explanatory texts on larger screens.

plurals
  1. POModal view controller not presented anymore after being presented 2/3 times
    text
    copied!<p>Here is the thing, I have to integrate an augmented reality functionality into an app. After testing it aside, now I'm ready to integrate it. The app always runs in Portrait, I decided to show the augmented reality when rotating the iPhone in Landscape Right or Left (and of course, if I go back in Portrait the original view controller is shown). In fact the augmented reality is presented modally. </p> <p>I've got viewController calling ARViewController (modally). It works fine if I rotate like 2 or 3 times, but then this ARViewController is not called anymore, but the app is still running, no crash, no freeze. This ARViewController is initialised with ARController, a class computing all needed for the augmented reality. If I call this ARViewcontroller without the ARController, switching between the view controllers works very fine, a blank window will be called but at least I can rotate the device as much as I want. So, this must come from the ARController, I documented myself on memory leaks (by the way I'm using ARC), I think this could be the reason to the issue since I'm using this ARController many times.</p> <p>But before going further, I'd like to know if I'm doing anything wrong that could influence the ARController by switching between view controllers:</p> <p>Here is how I call the ARViewController in viewController:</p> <pre><code>if (orientation == UIDeviceOrientationLandscapeLeft) { NSLog(@"ViewController Landscape left"); ARViewController *arVC = [[ARViewController alloc] initWithNibName:@"ARViewController" bundle:nil]; [self setCameraViewController:arVC]; [arVC setModalTransitionStyle: UIModalTransitionStyleFlipHorizontal]; [[self navigationController] presentModalViewController:cameraViewController animated:YES]; arVC = nil; } else if (orientation == UIDeviceOrientationLandscapeRight) { NSLog(@"ViewController Landscape Right"); ARViewController *arVC = [[ARViewController alloc] initWithNibName:@"ARViewController" bundle:nil]; [self setCameraViewController:arVC]; [arVC setModalTransitionStyle: UIModalTransitionStyleFlipHorizontal]; [[self navigationController] presentModalViewController:cameraViewController animated:YES]; arVC = nil; } </code></pre> <p>the initialisation of ARViewController:</p> <pre><code>- (void)viewDidLoad { [super viewDidLoad]; self.arController = [[ARController alloc] initWithViewController:self]; arController.filterDiscover = filterDiscover; arController.filterEat = filterEat; arController.filterSleep = filterSleep; // Listen for changes in device orientation [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deviceOrientationDidChange:) name: UIDeviceOrientationDidChangeNotification object:nil]; [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; //if ViewController presents this modal ARViewController if(!arController.filterDiscover &amp;&amp; !arController.filterEat &amp;&amp; !arController.filterSleep) [arController callAlertViewToFilter]; else [arController loadData]; } </code></pre> <p>And finally here is how I go back to the original view controller if I rotate to Portrait in ARViewController:</p> <pre><code>if (orientation == UIDeviceOrientationPortrait){ NSLog(@"ARViewController Portrait"); [self setArController:nil]; [[super presentingViewController] dismissModalViewControllerAnimated:YES]; } </code></pre> <p>I tried to be as clear as possible, if anyone has ever had an issue similar to this, it could be great have some clues to solve this. I could have shown the code of the ARController but it is a little too long, for now I'd just like to know if there is anything wrong here. If needed I'll show it.</p> <p>This might help, I found this output in the debug area when the ARViewController is not being displayed anymore:</p> <pre><code>2012-10-24 17:57:51.072 beiceland[20348:907] ViewController Landscape Right 2012-10-24 17:57:51.073 beiceland[20348:907] Warning: Attempt to present &lt;ARViewController: 0x203f0c60&gt; on &lt;RevealController: 0x1cd5dca0&gt; while a presentation is in progress! </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload