iPhone - 忽略视图问题
我正在查看一些使用 ARKIT 的增强现实示例。我试图在相机视图顶部添加一个按钮来关闭它,这样它就会转到上一个屏幕。当我尝试关闭视图时,相机关闭并冻结/停止在相机快门关闭动画处。 (此时我仍然可以看到该按钮,如果我再次按下它,应用程序就会崩溃)。
当前设置如下所示:主菜单视图 -> 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]];
}
i'm looking at some augmented reality examples using the ARKIT. I'm trying to add a button on top of the camera view to dismiss it, so it goes to its previous screen. When i try to dismiss the view, the camera shuts off and freezes/stops at the camera shutter close animation. (at this point i can still see the button, if i press it again it crashes the app).
The current setup looks like this : Main Menu View -> ARViewController -> Augmented Reality Controller. Maybe someone could tell me where i'm going wrong? or how if theres an easier way to forcefully close all views and display the main menu.
Here is some code :
Main Menu
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
}
Augmented Reality Controller
- (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]];
}
(original source code of the project https://github.com/kypselia/ARKit/blob/d4c018ce74e7c1abd786b6faa71d76435e52246f/ARKit/ARViewController.m)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不确定它是否可以解决您的问题,但您应该尝试仅使用dismissModalViewControllerAnimated一次,并且也使用
希望这会有所帮助...
Not sure if it can solve your problem but you should try using dismissModalViewControllerAnimated only once and tht too using
Hope this will help...