tags:

views:

156

answers:

1

I want to simulate some touches on my UI, without using private API.

So one simple way to do it is to simply call those -touchesBegan:withEvent:, -touchesMoved:withEvent:, -touchesEnded:WithEvent: and -touchesCancelled:withEvent: methods inside my custom controls. For that, I would have to create UITouch and UIEvent dummy objects with appropriate data inside. Is this fine with them? Or would they reject my app?

+1  A: 

There's no public constructors for UITouch and UIEvent, so no.

But you could just create a method which take any data type you like, and forward the -touches… methods to yours.

-(void)touchBegan:(CGPoint)location {
  // actual code.
}

-(void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event {
   [self touchBegan:[[touches anyObject] locationInView:self]];
}

 ...
   [self touchBegan:CGPointMake(23, 56)];
KennyTM