Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simulating System Wide Touch Events on iOS [duplicate]

Im trying to simulate a touch on as UIWebView, how can I programmatically fire a touch event at a certain location? (x and y coordinates) Just call touchesBegan?

Ideally I'd like to do it without any javascript hack because in the future it may not be a uiwebview

like image 521
Jonathan. Avatar asked Nov 25 '22 03:11

Jonathan.


2 Answers

It's not easy to synthesize a touch event on the iPhone: you have to use undisclosed API, so you have a high probability of breaking on every update of the iOS and getting rejecting from Apple.

Here's a link that demonstrates how to synthesize a touch event on the iPhone:

Here's another question on StackOverflow: How to send a touch event to iPhone OS?

like image 74
Sylter Avatar answered Jan 21 '23 09:01

Sylter


It's worth pointing out the KIF framework here. It's intended to run in the simulator but part of the code is simulating touch evens in code. with luck, this will be a good starting point.

https://github.com/square/KIF

Specifically, look at stepToTapViewWithAccessibilityLabel in KIFTestStep.m and the line

[view tapAtPoint:tappablePointInElement];
like image 24
Nate Avatar answered Jan 21 '23 09:01

Nate