How to make 'touchesBegan' method work for a specific view?
One way this is how you can do :
-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch= [touches anyObject];
if ([touch view] == image1)
{
//Action
}
}
Please Note : As you are using UIScrollView you might not able to get touches method for UIScrollView. In that case you might have to use UIGesture.
Here is the answer in Swift:
override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {
let touch = touches.first as! UITouch
if(touch.view == myView){
// Code
}
}
First check the property UserInteractionEnabled
of that whole controls and set to YES
After check out your bottom view frame that its not over on that views
And after you can checkout that with bellow condition and do something with particular controls touch event..
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
[touch locationInView:viewBoard];
if([touch.view isKindOfClass:[UIImageView class]])
{
UIImageView *tempImage=(UIImageView *) touch.view;
if (tempImage.tag == yourImageTag)
{
/// write your code here
}
}
}