Jump to content
10 posts in this topic

Recommended Posts

How can a touchesBegan method working for UIImageView?

 

inside touchesBegan

 

UITouch *touch = [[event allTouches] anyObject];

if([touch view] == imageView){

NSLog(@"touch imageView");

}

 

the imageView is a UIImageView, UITouch can't work when I touch the imageView.

 

Please Help!

Instead of the touchesBegan method, use the touchesMoved method. I think that should work.

I had try it and that's not work.

 

I think UITouch view method is only working with UIView instant.

 

Is there any other way to detect a UIImageView instant with UITouch method?

Watch this tutorial: Touches and UIImageViews. It covers how to use touches to move around an image.

 

yes I'm using the same tutorial, everything working fine be just

 

if([touch view] == UIImageView) <-- this one not working!

 

is there anything wrong or different version of xcode?

Why don't you just do this:

 

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event

UITouch *touch = [touches anyObject];

if([touch view] == imageView){

NSLog(@"touch imageView");

}

}

I think you are mistaking the event with the set of touches :rolleyes:

Find out the solution

 

New image view objects are configured to disregard user events by default. If you want to handle events in a custom subclass of UIImageView, you must explicitly change the value of the userInteractionEnabled property to YES after initializing the object.

×
×
  • Create New...