Mikayil Abdullayev
Mikayil Abdullayev

Reputation: 12367

Object at point

In my imageview I create and add new imageviews as subview every time the image is tapped twice. Then I've added single tap gesture to the newly added subview. When that subview(the new imageview) is tapped once I get navigated to another view controller. But, my problem is I get the latter effect only with the latest added subview. So let's say I've added 5 imageviews. I get navigated away only when I tap the 5th imageview. How can I make this happen no matter which subview is tapped?

Upvotes: 0

Views: 79

Answers (2)

highlycaffeinated
highlycaffeinated

Reputation: 19867

Without seeing the code, I can guess that you are using a GestureRecognizer to detect the tap in the added UIImageView. If that is the case, you can't reuse the recognizer since it can only be attached to one view. You'll need to create a new recognizer for each UIImageView you add to your main view.

Upvotes: 1

Example

while u create the uiimageview do set tag like this

UIImageView *iv=[[UIImageView alloc]init];

[iv setTag:0];




while tap identify and do exact with that like 

    [self.view viewWithTag:0]

Upvotes: 1

Related Questions