Sidwyn Koh
Sidwyn Koh

Reputation: 1742

How can I detect touches in the coordinateView of ARKit?

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?

Upvotes: 4

Views: 686

Answers (3)

Fernando Redondo
Fernando Redondo

Reputation: 1555

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!

Upvotes: 2

alloc_iNit
alloc_iNit

Reputation: 5183

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.

Upvotes: 1

ArturoNaredo
ArturoNaredo

Reputation: 99

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

[tempView bringSubviewToFront:testButton];

?

Upvotes: 2

Related Questions