Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

183
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda