如何检测ARKit坐标视图中的触摸?

发布于 2024-11-17 13:36:41 字数 468 浏览 0 评论 0原文

我当前的代码是这样的:

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];

但我没有收到任何按钮上的触摸。有什么想法吗?

My current code is as such:

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];

But I am not receiving any touches on the buttons. Any idea?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

感受沵的脚步 2024-11-24 13:36:41

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

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

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

最新的更新包含许多功能,其中包括单击特定坐标的功能。我会推荐每个增强现实极客查看 iPhone-AR-Toolkit!

I'll answer to my own bounty here.

This wonderful framework has now been updated by Niels Hansen:

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

The latest update contains, among many thing, the ability to click on specific coordinates. I'll recommend every Augmented Reality geek to check out the iPhone-AR-Toolkit!

你对谁都笑 2024-11-24 13:36:41

我对这段代码不太了解,但是......你尝试过吗:

[tempView bringSubviewToFront:testButton];

I don't know so much about this code but... did you try:

[tempView bringSubviewToFront:testButton];

?

无声无音无过去 2024-11-24 13:36:41

您可以添加 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];

我已经通过增强现实应用程序解决了同样的问题。希望,它也能帮助你。

You can add UITapGestureRecognizer, initialize it by a proper selector and assign this gesture to desired 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];

I have done for the same problem with Augmented Reality Application. Hope, it will help you out too.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文