How to achieve that one method is always called in every class
I guess this is very basic: I have a ViewController. In this ViewController I have a method called - (void)keyboardWillShow:(NSNotification *)notification {
etc. I just added another viewController to my app (called TabsEdit) and I would like that the keyboardWillShow method also applies to textfields in this TabsEdit class the same way it does in my ViewController.
Right now, it doesn't. I.e. if I edit a textField in my ViewController, I get all the ni开发者_如何学Cce things I told the keyboardWillShow method to do. If I edit a textField in my TabsEdit class, however, I will not get the keyboardWillShow method. I guess I could simply copy it into by TabsEdit.h, but that wouldn't be really good, I suppose. I defined it once, so that should be enough.
Any help would be very much appreciated. Thanks!
Make a class having keyboardWillShow method, derived from UIViewController, have your two other view controllers derive from this class. QED.
精彩评论