iPhone – How do I detect Touch on UIMageView in UiImageView?

I have a UIScrollview in my application, and I fill it with a large number of UI ImageViews for about 900. They are all very small and contain only two different images again and again. < p>

Now I have a lot of trouble detecting touches on one of the UIImageViews.

I have assigned them a unique label to be able to distinguish them, but I It’s really hard to find touch.

The goal is just to be able to change the image of the touched UIImageView.

Since a large number of views are involved, a simple loop to check the touch coordinates for each UIImageViews frame is just Hang my app.

Does anyone have any suggestions?

Thanks in advance.

This

solve this The best way to solve the problem is to subclass UIScrollView and add touchesBegan and other methods to it.

@interface MyScroll: UIScrollView
{

}

I have a UIScrollview in my app and I fill it with a lot of UI ImageViews for about 900. They are all small, time and time again Only two different images are included.

Now I have a lot of trouble detecting touches on one of the UIImageViews.

I have assigned them a unique Tags in order to be able to distinguish them, but I really have a hard time finding touches.

The goal is just to be able to change the image of the UIImageView that is touched.

Since a large number of views are involved, a simple loop Checking the touch coordinates for each UIImageViews frame just hangs my application.

Does anyone have any suggestions?

Thanks in advance.

This

The best way to solve this problem is to subclass UIScrollView, Add touchesBegan and other methods to it.

@interface MyScroll: UIScrollView
{

}

Leave a Comment

Your email address will not be published.