【发布时间】:2015-09-18 16:16:50
【问题描述】:
我已经从 Vuforia 成功构建了示例应用程序。我有兴趣采用 Cylinder Tracking 并将围绕汽水罐旋转的足球替换为不旋转但位于相对于罐子(跟踪图像的中心)的特定位置的按钮。
我是 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]; 行出现错误,说视图不是 self 的属性。
我意识到这可能不是正确的方法。我认为按钮需要呈现为 openGl 对象或其他东西,以便它是 3 维的,并且可以在移动目标时从某个角度看到。
有没有人这样做过或知道如何做到这一点?
【问题讨论】:
标签: ios objective-c opengl-es augmented-reality vuforia