Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

189
Views
swift get position of finger when is pressed longer

I have a scrollview and would like to get the exact position of the finger when the user presses the screen longer. Or if that's possible just get the position of the finger in a scrollview when the finger is moving.

So far I've tried using a LongGestureRecognizer. Here is my code, it all works, but I still need the exact position of the finger. Here how I created the Scrollview and the GestureRecognizer.

    testScroll = UIScrollView(frame: CGRect(x: 0, y: 0, width: width, height: height))
    self.view.addSubview(testScroll)
    testScroll.contentSize = CGSize(width: width, height: height*1.25)
    testScroll.delegate = self
    
    testREc = UILongPressGestureRecognizer(target: self, action: #selector(testprint(sender:)))
    testScroll.addGestureRecognizer(testREc)

if there is a possibility to get the position this way, or exactly via the (testprint func), it would be helpful for me

If you have any tips, I would appreciate your help.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Set the delegate of your UILongPressGestureRecognizer and implement gestureRecognizerShouldBegin().

There you can get the touch location that triggered the long press.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!