lamfan Posted August 4, 2008 Share Posted August 4, 2008 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! Link to comment https://www.insanelymac.com/forum/topic/119180-uitouch-not-working-for-uiimageview/ Share on other sites More sharing options...
Ilyace Posted August 4, 2008 Share Posted August 4, 2008 Instead of the touchesBegan method, use the touchesMoved method. I think that should work. Link to comment https://www.insanelymac.com/forum/topic/119180-uitouch-not-working-for-uiimageview/#findComment-843978 Share on other sites More sharing options...
lamfan Posted August 4, 2008 Author Share Posted August 4, 2008 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? Link to comment https://www.insanelymac.com/forum/topic/119180-uitouch-not-working-for-uiimageview/#findComment-844063 Share on other sites More sharing options...
Ilyace Posted August 4, 2008 Share Posted August 4, 2008 Watch this tutorial: Touches and UIImageViews. It covers how to use touches to move around an image. Link to comment https://www.insanelymac.com/forum/topic/119180-uitouch-not-working-for-uiimageview/#findComment-844097 Share on other sites More sharing options...
lamfan Posted August 4, 2008 Author Share Posted August 4, 2008 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? Link to comment https://www.insanelymac.com/forum/topic/119180-uitouch-not-working-for-uiimageview/#findComment-844177 Share on other sites More sharing options...
stroke Posted August 4, 2008 Share Posted August 4, 2008 Try: if([touch view] isTypeOfClass:UIImageView]) Link to comment https://www.insanelymac.com/forum/topic/119180-uitouch-not-working-for-uiimageview/#findComment-844982 Share on other sites More sharing options...
alloutmacstoday Posted August 4, 2008 Share Posted August 4, 2008 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 Link to comment https://www.insanelymac.com/forum/topic/119180-uitouch-not-working-for-uiimageview/#findComment-845043 Share on other sites More sharing options...
lamfan Posted August 5, 2008 Author Share Posted August 5, 2008 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. Link to comment https://www.insanelymac.com/forum/topic/119180-uitouch-not-working-for-uiimageview/#findComment-845294 Share on other sites More sharing options...
alloutmacstoday Posted August 5, 2008 Share Posted August 5, 2008 I was gonna say something about that, but I just couldn't remember the method used to enable it :/ Link to comment https://www.insanelymac.com/forum/topic/119180-uitouch-not-working-for-uiimageview/#findComment-845919 Share on other sites More sharing options...
lamfan Posted August 6, 2008 Author Share Posted August 6, 2008 I was gonna say something about that, but I just couldn't remember the method used to enable it :/ Thanks alloutmacstoday! Link to comment https://www.insanelymac.com/forum/topic/119180-uitouch-not-working-for-uiimageview/#findComment-846423 Share on other sites More sharing options...
Recommended Posts