Reputation: 36070
I have a UIViewController with a lot of methods therefore I will like to split it apart into separate classes to have my code more organized. I was wondering if it would be possible to place the
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
// code
}
method on a separate class.
Upvotes: 0
Views: 157
Reputation: 6279
The touch control functions apply to the UIView or UIViewController that you place them in. You can thus - to the best of my knowledge - not place them in a different class as is.
That said, if your goal is to clean up your code, you can subclass UIView and place an instance of that new UIView in your project instead of having the touches handled by your UIViewController. Make the UIView the size you want and set the alpha to 0 so users won't be aware of its existence.
If you only want touch recognition on a certain area of the screen this approach will make your life a lot easier as well.
Upvotes: 1