views:

228

answers:

2

Is there ever a time when the touchesBegan, touchesMoved, and touchesEnded methods would be handled inside a UIViewController vs. UIView?

I understand that they are typically used in a custom UIView but I am curious about this situation.

Thanks

A: 

Yes, they can be used in a view controller, and I have used this method multiple times. All you have to do is define these methods in the view controller and they will be called as it moves up the responder chain.

rickharrison
A: 

I would say the most likely time that you would want to put this stuff into the controller is when you are not subclassing UIView. I tend to put this in the controller to avoid subclassing just to add the touches methods.

Also, depending on what you are doing in the methods, it may be better MVC to put it in the controller. I guess you should consider if your code is "View" or "Controller" code and place it appropriately.

Joe Cannatti