barndog
barndog

Reputation: 7163

When would a view controller become the first responder?

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.

Upvotes: 0

Views: 1942

Answers (1)

Mitchell Currie
Mitchell Currie

Reputation: 2809

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

Upvotes: 2

Related Questions