0

I need to collect all touch data from the touch screen (touch location, type, timestamp, force, and other interaction with touch screen) in an application running on the operating system iOS.

But my problem is that such function as touchesBegan, touchesMoved and touchesEnded work only for views and do not work when I use scroll (when content is larger than the size of the application's window).

I can recognise tap gesture almost on all controllers, but now, I am interested in getting data from touchesMoved. Is it possible?

As soon as the scroll bar appears, the touchesMoved stop working. How can I implement the task of collecting all touch data from touch screen? I'd like to limit the coordinate plane by the phone screen, if it is possible.

Melebius
  • 6,183
  • 4
  • 39
  • 52
Alina
  • 1
  • 1
  • you need to Subclass uiscrollview to allow it to correspond to uitouch delegate methods. check here https://stackoverflow.com/questions/7439273/uiscrollview-prevents-touchesbegan-touchesmoved-touchesended-on-view-controlle – Rishabh Nov 06 '17 at 09:23
  • @Rishabh thank you! I did it, but I need get data all times, while finger touches the screen. Swift is a new language for me, and there are a lot of difficulties. Function `touchesMoved` is not called all the time. And `touchesEnded` is called only when I tap on the screen (without moving). Can I change it? – Alina Nov 06 '17 at 10:09
  • As soon as the scroll bar appears all of these function stop working... – Alina Nov 06 '17 at 10:28
  • Yes Alina, that happens because scrollview also implements its own functionality for dragging the content in content view. Therefore, if you check the subclass link, it has an if-else condition that checks if the scrollview is dragging or not and only fires touch methods when dragging is not active. If you want to capture all the touch data then you should try to implement the touch methods on the superview of your scrollview. – Rishabh Nov 06 '17 at 10:31
  • @Rishabh Rishabh, thank you very much. Yes, I saw if-else condition. And.. I can't understand what happened, when dragging is active. As I could understand, when dragging is active, the touch coordinate relative to the touch screen changes, but the touch coordinate relative to view is not, right? And now I can't understand, is it possible to implement my task or not? Is it possible to capture all touch data in this case? (Excuse me for my misunderstanding, and for my English) – Alina Nov 06 '17 at 10:52
  • I dont think you can do that using these methods that respond to touches. You should try to implement scrollview delegate methods instead and try to calculate touches in those. Also all the touches began/moved etc are methods that are implemented in uiresponed class not the uiview class. Also scrollviews dont respond to the touchesMoved method due to its dragging implementation. – Rishabh Nov 06 '17 at 11:43

0 Answers0