如何检测ARKit的coordinateView中的触摸?

时间:2011-06-27 09:22:17

标签: iphone uiview augmented-reality

我目前的代码是这样的:

UIButton *testButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    testButton.frame = CGRectMake(0, 0, 100, 100);
    [testButton setTitle:@"HELLOHELLOHELLO" forState:UIControlStateNormal];
    [testButton addTarget:self action:@selector(pushPhoneDetailController:) forControlEvents:UIControlEventTouchUpInside];
    testButton.tag = toPutTag;
    [tempView addSubview:testButton];

但是我没有接触到任何按钮。有什么想法吗?

3 个答案:

答案 0 :(得分:2)

我对这段代码了解不多但是......你试过了吗?

[tempView bringSubviewToFront:testButton];

答案 1 :(得分:2)

我会在这里回答我自己的赏金。

这个精彩的框架现已由Niels Hansen更新:

https://github.com/nielswh/iPhone-AR-Toolkit

最新更新包含点击特定坐标的功能。我会推荐每个Augmented Reality geek来查看iPhone-AR-Toolkit!

答案 2 :(得分:1)

您可以添加UITapGestureRecognizer,通过适当的选择器对其进行初始化,并将此手势指定给所需的UIControl。

    UIImageView *myImgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:img]];
    myImgView.frame = CGRectMake(0, 10, 230, 145);        
    [myImgView addGestureRecognizer:tap];
    [tap release];
    [self.view addSubView:frame];

    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(imageTapped:)];
    [myImgView addGestureRecognizer:tap];
    [tap release];

我已经为增强现实应用程序做了同样的问题。希望,它也会帮助你。