0
我正在看一些使用ARKIT的增強現實示例。我試圖在相機視圖頂部添加一個按鈕來解除它,因此它會轉到其前一個屏幕。當我嘗試關閉視圖時,相機會關閉並凍結/停止相機快門關閉動畫。 (在這一點上,我仍然可以看到按鈕,如果我再次按它它崩潰的應用程序)。iPhone - 關閉查看問題
當前設置如下所示:主菜單視圖 - > ARViewController - >增強現實控制器。也許有人可以告訴我我哪裏出錯了?或者如果這是更簡單的方法來強制關閉所有視圖並顯示主菜單。
下面是一些代碼:
主菜單
if([ARKit deviceSupportsAR])
{
ARViewController *viewController = [[ARViewController alloc] initWithDataSource:self];
viewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:viewController animated:YES];
[viewController release];
}
ARViewController
.h
AugmentedRealityController *agController;
.m
- (void)loadView {
self.agController = [[AugmentedRealityController alloc] initWithViewController:self];}
- (void)viewDidAppear:(BOOL)animated
{
[agController displayAR];
}
- (void) scanButtonPressed { //action when button is pressed
[agController hideAR]; //dismiss camera
[self dismissModalViewControllerAnimated:YES]; //dismiss current view
}
增強現實控制器
- (void) hideAR {
[[self locationManager] stopUpdatingHeading];
[[self locationManager] stopUpdatingLocation];
[[self accelerometerManager] release];
[rootViewController dismissModalViewControllerAnimated:YES];
}
// This is needed to start showing the Camera of the Augemented Reality Toolkit.
-(void) displayAR {
[rootViewController presentModalViewController:[self cameraController] animated:NO];
[displayView setFrame:[[[self cameraController] view] bounds]];
}