Question

I'm learning about the responder chain in iOS and about first responders and I was wondering , what are the use cases that a UIViewController would become or need to become a first responder?

For example, I'm doing an animation on a UILabel so that for every pixel the user drags their finger, the label moves with it. I'm overriding touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event and all those methods as you should but I need to be able to tell where the user is dragging, outside the context of the view. I feel like that's a potential use case where I would want my view controller to be the first responder and have all the methods in with the view controller code.

Était-ce utile?

La solution

The View Controller should normally be first responder until a UIControl takes over. Please see this question for a better response. Similar Question

I think however, you will be better served by using a UIGestureRecognizer See Docs

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top