这是事情,我必须将增强现实功能集成到应用程序中。经过测试,现在我已经准备好整合它了。该应用程序始终以纵向模式运行,我决定以横向或左侧旋转iPhone时显示增强现实(当然,如果我以纵向显示原始视图控制器,则返回)。事实上,增强现实是以模态方式呈现的。模态视图控制器在呈现2/3次后不再呈现
我有viewController调用ARViewController(模态)。它可以正常工作,如果我旋转2或3次,但这个ARViewController不再被调用,但应用程序仍在运行,没有崩溃,没有冻结。此ARViewController使用ARController进行初始化,ARController是增强现实所需的一类计算。如果我在没有ARController的情况下调用这个ARViewcontroller,那么在视图控制器之间切换工作得很好,将会调用一个空白窗口,但至少我可以根据需要旋转设备。所以,这必须来自ARController,我记录了自己的内存泄漏(按照我使用ARC的方式),我认为这可能是导致问题的原因,因为我多次使用此ARController。
但在进一步,我想知道如果我做错什么,可以通过视图控制器之间的切换影响ARController:
这里是我所说的ARViewController中的viewController:
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;
}
ARViewController的初始化:
- (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 && !arController.filterEat && !arController.filterSleep)
[arController callAlertViewToFilter];
else
[arController loadData];
}
最后这里是我回到原来的视图控制器,如果我旋转肖像ARViewController:
if (orientation == UIDeviceOrientationPortrait){
NSLog(@"ARViewController Portrait");
[self setArController:nil];
[[super presentingViewController] dismissModalViewControllerAnimated:YES];
}
我试图尽可能清楚,如果任何人有过类似这样的问题,也可能是巨大的有一些线索来解决这个问题。我可以显示ARController的代码,但它有点太长了,现在我只想知道这里是否有任何问题。如果需要,我会展示它。
这也许会有帮助,我发现在调试区,该输出将不被再显示ARViewController:
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 <ARViewController: 0x203f0c60> on <RevealController: 0x1cd5dca0> while a presentation is in progress!
我试过pushViewController,起初它似乎是显示AR的最明显的方式。但由于我的应用程序只有肖像的方向限制(项目设置),当我显示AR时,只有3/4的屏幕区域是活动的touchesBegan,奇怪...使用模态它工作正常。没有它,我会使用pushViewController。对不起,我没有得到你说的那些东西。 –
对不起,我的意思是说,也许你可以发布代码[超级presentsViewController] – Snaker
对不起,但唯一我发现足够接近你的最新警告是[this](http://stackoverflow.com/questions/12596882/modal -uinavigationcontroller-hides-though-not-dismisses) – Snaker