【问题标题】:vuforia and uinavigationcontrollervuforia 和 uinavigationcontroller
【发布时间】:2012-11-15 06:44:47
【问题描述】:

我有一个由 Unity3D 生成的 xCode 项目(包括动画),并且我已经集成了 vuforia SDK 用于显示动画(增强现实)

我现在遇到的问题是在相机屏幕和我的应用程序的仪表板之间添加导航。

int OpenEAGL_UnityCallback(UIWindow** window, int* screenWidth, int* screenHeight, int* openglesVersion) 方法中,我实用地添加了后退按钮:

if (wrapperObj == nil)
{
    wrapperObj = [[WrapperClass alloc] init];
}

[backButton addTarget:wrapperObj action:@selector(goToDashBoard:) forControlEvents:UIControlEventTouchUpInside];

将其传递给包装类

@interface WrapperClass : NSObject

@property (nonatomic, retain) UINavigationController *navigation;

-(void)goToDashBoard:(UIButton*)sender;

@end

void goToPreviousScreen()
{

}

@implementation WrapperClass
@synthesize navigation;

-(void) goToDashBoard:(UIButton*)sender
{
    [[self navigation] popViewControllerAnimated:YES];
    goToPreviousScreen();
}

@end

谁能告诉我如何让导航启动并运行的解决方案?

更新

当尝试以这种方式弹出视图时:

AppDelegate *appDelegate = [UIApplication sharedApplication].delegate;
[appDelegate.navigationController popToRootViewControllerAnimated:YES];

我得到了这个日志:

2012-12-05 16:20:45.502 arapp[5993:907] <HomeViewController: 0x246db00>

StopQCAR

(Filename: /Applications/buildAgent/work/14194e8ce88cdf47/Runtime/ExportGenerated/iPhonePlayer-armv7/UnityEngineDebug.cpp Line: 43)

Could not deactivate dataset.

(Filename: /Applications/buildAgent/work/14194e8ce88cdf47/Runtime/ExportGenerated/iPhonePlayer-armv7/UnityEngineDebug.cpp Line: 43)

Could not destroy dataset.

(Filename: /Applications/buildAgent/work/14194e8ce88cdf47/Runtime/ExportGenerated/iPhonePlayer-armv7/UnityEngineDebug.cpp Line: 43)

Could not deinitialize the tracker.

(Filename: /Applications/buildAgent/work/14194e8ce88cdf47/Runtime/ExportGenerated/iPhonePlayer-armv7/UnityEngineDebug.cpp Line: 43)

Could not deinitialize the tracker. 

(Filename: /Applications/buildAgent/work/14194e8ce88cdf47/Runtime/ExportGenerated/iPhonePlayer-armv7/UnityEngineDebug.cpp Line: 43)

ghashtable.c:294: assertion 'hash != NULL' failed

【问题讨论】:

    标签: iphone ios uinavigationcontroller ios6 unity3d


    【解决方案1】:

    如果我正确理解了您的问题,您正试图通过添加文件、视图控制器、代码等来修改 Unity 构建的 Xcode 项目。根据我的经验,这不是一个好主意,您最好尽可能在 Unity 中构建您的应用程序。 Vuforia 论坛的版主也强烈反对它。我以这种方式构建了一个 Unity/Vuforia 应用程序,主要是为了避免花时间学习如何在 Unity 中使用 C# 进行操作。我最终遇到了无法追踪的内存泄漏,不得不硬着头皮回到 Unity 并学习 Unity 脚本。当然有很多 iOS 的事情你在 Unity 中是做不到的,我不知道你的应用是做什么的,但是有很多插件可以帮助你,我结束了学习如何编写自己的插件来获得一些 iOS 功能我需要。

    但是,如果您想像我那样在 AR 视图和其他视图控制器之间导航,则可以创建另一个 viewController,它基本上是一个覆盖层,只包含导航按钮。然后我对其进行了初始化并将其作为子视图添加到 UnityViewController。然后添加代码以转到所需的任何视图,例如仪表板。

    // Init Vuforia VC, then add its view as subview  to "view" AR view, line 524
    VuforiaViewController *vuforia = [[VuforiaViewController alloc] init];
    
    // Create a full-screen window
    _window = [[UIWindow alloc] initWithFrame:rect];
    EAGLView* view = [[EAGLView alloc] initWithFrame:rect];
    UnityViewController *controller = [[UnityViewController alloc] init];
    
    sGLViewController = controller;
    sGLView = view;
    
    
    
    controller.view = view;
    
    _splashView = [ [UIImageView alloc] initWithFrame: [[UIScreen mainScreen] bounds] ];
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
    {
        _splashView.image = [UIImage imageNamed:SplashViewImage(UIInterfaceOrientationPortrait)];
    }
    else
    {
        _splashView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
        _splashView.autoresizesSubviews = YES;
    }
    
    
    
    
    [view addSubview:_splashView];
    [view addSubview:vuforia.view];     // Overlay view added as subview of AR view
    

    您可能知道,您可以在 AppController 中注释掉 startUnity() 以防止在应用启动时出现 AR 视图,并在另一个 VC 中调用它以返回 AR 视图。这种方法让我可以在 AR 视图和其他几个 VC 视图之间导航,但最终该应用程序不稳定,必须更换为完全内置于 Unity 中的应用程序。也许您可以找到更好的方法,但您最好还是深入研究 Unity 和插件,这取决于您希望您的应用程序做什么。希望这可以帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-17
      • 1970-01-01
      • 2012-11-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多