Charlie Charlie - 1 year ago 67
iOS Question

How can you create an accessoryInputView in a Storyboard design?

I am trying to create an accessoryInputView to augment the keyboard with some app-specific keys.

I am using a Storyboard based design approach to keep the the UI separated from the application logic.

I cannot seem to understand how to create the new view and associated it with the textView. Is it possible?


In case anyone else is trying to do this, let me record what I ended up doing.

I created a new XIB with the accessoryView I wanted in it. I could not figure out how to assign the inputAccessoryView directly into a storyboard design, so I did the following.

I made the fileOwner of the XIB as the controller class that contains the textView that needs the accessoryView and assigned the view to a IBOutlet in that class. That allows me to load the XIB and auto-assign it to the IBOutlet.

Then in the viewDidLoad, I assign the IBOutlet to the textView that needs it. It works well and allows me to do all the UI work in IB and keep the logic in the controller. I guess I can consider setting the inputAccessoryView as 'logic' and not UI design and consider this a good design. Not stellar, since IB does not allow setting the inputAccessoryView directly from a XIB or creating views in a storyboard that are not part of the flow of the app.

The code in viewDidLoad looks like:

- (void) viewDidLoad
    [super viewDidLoad];
    [[NSBundle mainBundle] loadNibNamed:@"NoteInputAccessoryView" owner:self options:nil];