开发者

How to achieve that one method is always called in every class

开发者 https://www.devze.com 2023-03-02 21:33 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消