I am trying to create a generalized class for managing my keyboard and adding a toolbar to that keyboard. I have several ViewControllers that will be accessing this class. This class will have several methods, one of which will be addToolbar.
Let’s do a small example here:
When my MainViewController loads, it will call viewDidLoad. Normally on viewDidLoad it will have to create a new toolbar and add it to each text field by calling setInputAccessoryView:. What I want to do is just call a separate class (our keyboard manager), but that keyboard manager will need to be able to access the MainViewController‘s text fields and be able to call setInputAccessoryView on them.
Is this possible? If so, how can I get started with it?
My
MainViewControllerloads, callingviewDidLoad.and the
UIToolbar *toolbar = [keyboard kbToolbarAndNotifReg:textFieldArray];is where the real stuff lies. It registers for notifications for scrolling the scrollView (not completed yet), then thekeyboardsaves thetextFieldArrayfor future use, and it also creates a toolbar to go on top of the keyboard and returns it. I then loop around andsetInputAccessoryView:toolbarin theMainViewController.When the text field is tapped, a notification is called (one of the notifications we registered for earlier in
keyboard), and calls a local method insidekeyboardthat has the array information we need. I am still working on completing this, but so far it’s coming along nicely.