I have a multiview iPhone app I’m developing that will have lots of inputs on different screens and instead of having to repeat myself all over the place with some method that just sends the resignFirstResponder message, I thought I would make a static method in my root controller class and solve all my resignFirstReponder needs with a single function. Is that possible? I can’t seem to drag the root controller .h file into the Interface builder and if I try to drop the class in there I can’t hook any events up to it. Is there a way to hook events up to an IBAction method that is static?
Edit:
I should have been more clear in what I’m trying to accomplish. Basically, I call resignFirstResponder in the “Did End On Exit” event of text fields to get rid of the keyboard. (Is this even the correct way? I’m an iPhone newbie) Because I’m going to be using this all over the place on different views, I didn’t want to have to write the same function for each view. I want to have a +(void) resignSomeKeyboardsOrSomething kind of function in my root controller that I can hook my “Did End On Exit” events up to from each view. Is there a way to do that? Sorry for the vagueness the first time around.
Let me see if I understand this, you have an application with multiple screens that do all sorts of things and you want these things to trigger a function, correct?
It sounds to me like notifications will work well for you.
So let’s say you have a function, resignMyResponder, defined in your root view controller. Just add the following to your root view controller file, in your initialization function:
Then, in your other screens/files, whenever you’d like resignMyResponder called, simply do:
resignMyResponder will probably need to be pretty complex to handle all the different situations in which it might get called, but that depends on the implementation of your application.