Alex Rivera | Logout

iPhone first responders

Asked 2010-04-10T03:40:57.837
9

I am confused about the iPhone responder chain. Specifically, in the iPhone event handling guide http://developer.apple.com/iPhone/library/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/EventHandling/EventHandling.html, we have the following:

The first responder is the responder object in an application (usually a UIView object) that is designated to be the first recipient of events other than touch events.

But UIView is a subclass of UIResponder. And the UIResponder class reference says this:

- (BOOL)canBecomeFirstResponder

Return Value

YES if the receiver can become the first responder, NO otherwise. Discussion

Returns NO by default. If a responder object returns YES from this method, it becomes the first responder and can receive touch events and action messages. Subclasses must override this method to be able to become first responder.

I am confused by the apparent contradiction. Can anyone clear it up for me?

For what it's worth, I did set up a simple view-based application, and call canBecomeFirstResponder and isFirstResponder on its view. Both returned NO.

Edit
Report

1 Answer

9

What this means is that the basic UIView is not able to become first responder - it doesn't do anything with motion events, editing-menu messages, etc.

Some UIView subclasses (like UITextView) are able to become first responder, and you can write your own UIView subclass that does so too.

answered 2010-04-10T03:51:46.743

Your Answer