【问题标题】:iPhone - Dismiss View problemiPhone - 关闭视图问题
【发布时间】:2011-11-09 02:40:53
【问题描述】:

我正在查看一些使用 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]];
}

(项目原源码https://github.com/kypselia/ARKit/blob/d4c018ce74e7c1abd786b6faa71d76435e52246f/ARKit/ARViewController.m)

【问题讨论】:

    标签: objective-c xcode ios4 uiviewcontroller modalviewcontroller


    【解决方案1】:

    不确定它是否能解决您的问题,但您应该尝试只使用一次 dismissModalViewControllerAnimated 并且也使用

    [self dismissModalViewControllerAnimated:YES]; 
    

    希望这会有所帮助...

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-05
      相关资源
      最近更新 更多