Search code examples
objective-cioscocoa-touchfirst-responder

Resign first responder from separate class


I have a class that makes a keyboard toolbar which has "Next", "Previous", and "Done" buttons on it. Is there a way for this class to know (or find out) what objects are on the screen at any time?

E.g., can it see what the current view is and what the text fields on it are, and then be able to resign the first responder?


Solution

  • Is there a way for this class to know (or find out) what objects are on the screen at the time?

    Find the momma view and you can iterate through all the objects on the screen (because they will be UIViews too) like this. Note that you may need to add recursion:

    for (UIView *view in mommaView.subviews) {
        do something to the view
    }