Vuforia IOS 圆柱体示例 - 添加按钮

Vuforia IOS cylinder example - Add button

我已经从 Vuforia 成功构建了示例应用程序。我有兴趣采用圆柱体跟踪并将围绕汽水罐旋转的足球替换为一个按钮,该按钮不旋转但位于相对于罐子(跟踪图像的中心)的特定位置。

我是 iOS 开发的新手,我不太清楚如何做到这一点。理想情况下,这将以编程方式完成。

我可以使用以下代码向 CylinderTargetsViewController.mm 添加一个按钮:

- (void)viewDidLoad
{
 [super viewDidLoad];
 UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
 [button setTitle:@"Gossamer Rules" forState:UIControlStateNormal];
 [button sizeToFit];
 button.center = CGPointMake(320/2, 60);
 [button addTarget:self action:@selector(buttonPressed:)
 forControlEvents:UIControlEventTouchUpInside];
 [self.view addSubview:button];
}

- (void)buttonPressed:(UIButton *)button {
    UIApplication *mySafari = [UIApplication sharedApplication];
    NSURL *myURL = [[NSURL alloc]initWithString:@"http://www.example.com"];
[mySafari openURL:myURL];
}

然而,无论是否找到目标,这都会在屏幕上添加一个按钮,并且它与目标没有空间关系。

我尝试将此代码移至 CylinderTargetsEAGLView.mm,但在第 [self.view addSubview:button]; 行出现错误,指出视图不是自身的 属性。

我意识到这可能不是正确的方法。我认为按钮需要呈现为 openGl 对象或其他东西,以便它是 3 维的,并且在移动目标时可以从某个角度看到。

有没有人做过这个或者知道如何做?

我决定使用 Vuforia Unity Package,因为尝试学习纯 OpenGL 编程的学习曲线要​​陡峭得多。 Unity 路线有更大的社区支持,并且有更多的教程/信息可用。