Questions tagged [touchesbegan]

Use this tag for questions related to touchesBegan:withEvent, a UIResponder event-handling method in the UIKit framework and MonoTouch.UIKit Namespace.

touchesBegan:withEvent: is a UIResponder event-handling method in the UIKit framework and MonoTouch.UIKit Namespace that is triggered when one or more fingers touches the screen.

Along with touchesCancelled:withEvent:, touchesEnded:withEvent:, and touchesMoved:withEvent:, it is one of the primary touch event-handling methods.

Syntax Examples

func touchesBegan(_ touches: Set<UITouch>,
     withEvent event: UIEvent?)

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

[MonoTouch.Foundation.Export("touchesBegan:withEvent:")]
public virtual Void TouchesBegan (NSSet touches, UIEvent evt)

Resources

Related Tags

451 questions
61
votes
11 answers

How do I detect if an SKSpriteNode has been touched

I am trying to detect if my sprite node has been touched and I have no idea where to start. let Pineapple = SKSpriteNode(imageNamed: "Pineappleimg") Pineapple.userInteractionEnabled = true Pineapple.position = CGPoint(x: CGRectGetMidX(self.frame) -…
James Brennan
  • 635
  • 1
  • 6
  • 7
44
votes
14 answers

How to Zoom In/Out Photo on double Tap in the iPhone WWDC 2010 - 104 PhotoScroller

I am going through the Sample code of iPhone WWDC 2010 - 104 PhotoScroller App. It's working great with my project related images (PDF Page Images) but I am struggling detect touches in the PhotoScroller App. The Zooming using multiple touches is…
Roger_iPhone
  • 737
  • 1
  • 9
  • 20
21
votes
5 answers

touchesBegan method not called in UITableViewController class in iPhone

How can I use touchesBegan: withEvent: method in UITableViewController class? UITableViewController is a subclass of UIViewController class. So why the method does not works in UITableViewController?
Confused
  • 3,846
  • 7
  • 45
  • 72
20
votes
4 answers

touchesBegan, touchesEnded, touchesMoved for moving UIView

I need to drag my UIView object. I use this code, but it does not work float oldX, oldY; BOOL dragging; - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [[event allTouches] anyObject]; CGPoint…
Matrosov Oleksandr
  • 25,505
  • 44
  • 151
  • 277
19
votes
5 answers

Get the coordinates of a point from mkmapview on iphone

I'm trying to figure out how to put an annotation on a map based on where the user touches. I have tried sub-classing the MKMapView and looked for the touchesBegan to fire but as it turns out, MKMapView does not use the standard touches methods. I…
AtomRiot
  • 1,869
  • 3
  • 18
  • 24
19
votes
3 answers

How can I shorten the time "delayTouchesBegan" delays touchesBegan?

In one of my view controllers I have several views that contain a UITapGestureRecognizer, along with an implementation of touchesBegan. I need to prioritize the taps over touchesBegan so I set the delaysTouchesBegan property of the gesture…
pasawaya
  • 11,515
  • 7
  • 53
  • 92
16
votes
2 answers

How do you tell what object is being touched in touchesBegan?

I know that this is a very commonly asked question, but all of the answers on every website don't work! If you still don't know what I mean, then maybe this line of code will help you understand. - (void)touchesBegan:(NSSet *)touches…
Flafla2
  • 691
  • 2
  • 11
  • 21
15
votes
1 answer

UIGestureRecognizers vs touchesBegan/touchesMoved/touchesEnded (accuracy)

I was printing the list of points I get using this two methods of touch tracking. The gesture recognisers are easier to use, but if you compare the points you get with the touchesBegan procedure, recognisers avoid some points, specifically at the…
Omer
  • 5,470
  • 8
  • 39
  • 64
13
votes
6 answers

Nested UIScrollViews and event routing

I have 2 scroll views, both of which are supposed to scroll vertically. The outer scroll view (red) contains a search bar and the inner scroll view (blue). The inner scroll view is supposed to scroll infinitely (it contains images/items and has an…
Sebastian
  • 2,889
  • 4
  • 34
  • 37
11
votes
2 answers

touchesBegan is called in iOS 12 but is not called in iOS 13

I have a touchesBegan method in my AppDelegate. I use it to detect taps in the status bar. I've had it there for a long time and it's worked great. Until the iOS 13 betas came out... Ever since using iOS 13 touchesBegan has stopped being called.…
Xeaza
  • 1,410
  • 1
  • 17
  • 21
11
votes
1 answer

Long press only in didSelectRowAtIndexPath

I've asked a similar question, and I've read countless other questions but I still can't figure this out and I've spent a few nights now trying to solve it. I have a custom UITableView class which I have subclassed to call different things. In my…
LateNate
  • 763
  • 9
  • 22
10
votes
4 answers

How to track touches in a consistent way between touchesBegan: and touchesEnded:?

In some maintenance of some multitouch "drawing on screen" code, I met a bug relative to how references to touches instances should be set between touchesBegan:withEvent:, touchesMoved:withEvent: and touchesEnded:withEvent:. The code uses a…
Mick F
  • 7,312
  • 6
  • 51
  • 98
10
votes
3 answers

What is the difference between beginTrackingWithTouch and touchesBegan?

Can someone please explain the high-level difference between these two methods? In particular, when would you use one over the other, and is there any overlap in terms of the purposes of these methods? They seem like they serve the same purpose but…
rmp251
  • 5,018
  • 4
  • 34
  • 46
10
votes
5 answers

How to get current touch point and previous touch point in UIPanGestureRecognizer method?

I am new to iOS, I am using UIPanGestureRecognizer in my project. In which I have a requirement to get current touch point and previous touch point when I am dragging the view. I am struggling to get these two points. If I use touchesBegan method…
9
votes
1 answer

Swift: Agar.io-like smooth SKCameraNode movement?

If anyone here has played Agar.io before, you'll probably be familiar with the way the camera moves. It slides toward your mouse depending on the distance your mouse is from the center of the screen. I'm trying to recreate this movement using an…
MysteryPancake
  • 1,365
  • 1
  • 18
  • 47
1
2 3
30 31