uitouch
UIButton TouchUpInside Touch Location
UITouch *theTouch = [touches anyObject]; CGPoint where = [theTouch locationInView:self]; NSLog(@” touch at (%3.2f, %3.2f)”, where.x, where.y); That’s the right idea, except that this code is probably inside an action in your view controller, right? If so, then self refers to the view controller and not the button. You should be passing a pointer to … Read more
Detect if certain UIView was touched amongst other UIViews
In order to check whether certain view inside another view was touched you can use hitTest. – (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event; In your custom implementation of touchesBegan check every touch in touches set. The point for hitTest method can be obtained using – (CGPoint)locationInView:(UIView *)view; method, where the view is your superView (the one that … Read more
How to Zoom In/Out Photo on double Tap in the iPhone WWDC 2010 – 104 PhotoScroller
I researched several different web sites and I came up with the following… Place this code into your viewDidLoad or viewWillAppear method: ////////////////////////////// // Listen for Double Tap Zoom UITapGestureRecognizer *doubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleDoubleTap:)]; [doubleTap setNumberOfTapsRequired:2]; [self.scrollView addGestureRecognizer:doubleTap]; [doubleTap release]; Add this to your header file: – (void)handleDoubleTap:(UIGestureRecognizer *)gestureRecognizer; Add this to your … Read more
UIScrollview getting touch events
Set up a tap gesture recognizer: UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(singleTapGestureCaptured:)]; [scrollView addGestureRecognizer:singleTap]; and you will get the touches in: – (void)singleTapGestureCaptured:(UITapGestureRecognizer *)gesture { CGPoint touchPoint=[gesture locationInView:scrollView]; }
How can I detect the touch event of an UIImageView?
In practical terms, don’t do that. Instead add a button with Custom style (no button graphics unless you specify images) over the UIImageView. Then attach whatever methods you want called to that. You can use that technique for many cases where you really want some area of the screen to act as a button instead … Read more
Click Event on UIImageView programmatically in ios
SWIFT 5 let preArrowImage : UIImageView // also give it frame let singleTap = UITapGestureRecognizer(target: self, action: #selector(tapDetected)) preArrowImage.isUserInteractionEnabled = true preArrowImage.addGestureRecognizer(singleTap) //Action func tapDetected() { print(“Imageview Clicked”) } Objective-c UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapDetected)]; singleTap.numberOfTapsRequired = 1; [preArrowImage setUserInteractionEnabled:YES]; [preArrowImage addGestureRecognizer:singleTap]; -(void)tapDetected{ NSLog(@”single Tap on imageview”); }