In my app, I have many different functions. These are view controllers that are all subclasses of my custom class, Function. By subclassing function, they inherit standard things like a background image, or the appropriate nav buttons.
My question is, can I put some code in function's viewDidLoad, that will enable it to set parameters for UITextFields in any controller that subclasses it. So basically is it possible to get all the properties of a class with a certain class (in this case UITextField)?
What I intend to do with this (apart from standa开发者_运维技巧rdising the keyboards, setting the delegate etc.), is to create a UIToolbar with previous and next buttons on, which automatically takes you between text fields (without having to code it for each function). I know you can enumerate through text fields in the iOS simulator (by pressing tab), but is this an OS-wide thing?
Also if you could enumerate through text fields, I could make an app-wide hideKeyboard method and lots of other useful things...
Thanks in advance, I would appreciate any advice.
You want to implement the UITextFieldDelegate
in your superclass. Each subclass should be responsible for creating a list (NSArray) of the text fields. Once you have that, you can tell if you are leaving the "last" text field, and go to the next controller.
If you want to "tab" to the next field, you can tag them (or keep them in a list) and use the delegate methods and becomeFirstResponder
to change the "key field".
精彩评论