0
votes

I checked the documentation related to First Responder but couldn't find some sort of callback which is received when some UIView resigns from being the first responder. Let me explain my scenario.

So, I have a custom UIView (created programmatically) which becomes the first responder when invoked. Now I want to dismiss/remove this view when the user clicks on the superview or some other view. I have written the logic in super view to make it as first responder when it receives a touch event but couldn't find any callback for that custom view to dismiss it when this happens.

Taking another view point I want to get a similar behavior as of the textfield's keyboard, which is dismissed when some other view becomes the first responder.

I hope my questions context is clear.

2

2 Answers

1
votes

Since UIView inherits from UIResponder, you can just override the resignFirstResponder method to update your appearance as necessary:

- (BOOL)resignFirstResponder {
    if (![super resignFirstResponder])
        return NO;

    // dismiss self here
    return YES;
}
0
votes

I assume you have implemented all the other view's IBAction methods when being touched. So why not in those methods let this custom view resign first responder or even be released if you find this custom view is not nil and is not needed anymore?