Question

I am trying to implement a session management for a new module to a existing code base in which the main.m, Appdelegate and UIApplication files are bundled in a library and we have no access to modify it.

I have tried by adding Gesture recognizer to UIWindow method to track the touch events but the usual button touch events were misbehaving.

Now am planning to subclass UIView and overwrite touches began and hit test method and make all my UIView class implements this custom UIView class.

Do we have any better approach to track the touch events apart from the above mentioned approaches?

Was it helpful?

Solution

Best approach will be overwriting send event of UIApplication and UIWindow but its not possible in your case.

Try to add UIGestureRecognizer to your application shared UIWindow then set its delegate and implement below delegate method.

-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch 
{
     return NO; 
}

By returning NO will prevent the gesture recognizer from seeing this touch object. You can add your implementation for tracking touch event inside this method.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top