My Silver Challenge Solution for all textView objects


I used the inputAccessoryView as others suggested; however I implemented differently so that the button shows up for all textView objects and releases their respective inputViews.

[ul]Override the getter, - (UIView*)inputAccessoryView, so that it returns the custom toolbar with a target/action pairing.
Implement the action method, - (void)doneEdit:(id)sender, to resignFirstResponder for all of the textView objects.[/ul]

- (UIView *)inputAccessoryView
    // Instantiate a UIToolbar and *very important* size it
    UIToolbar *toolBar = [[UIToolbar alloc] init];
    [toolBar sizeToFit];
    // create a UIBarButtonItem and associate a target action pairing
    UIBarButtonItem *bbi = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone
    // add the bar button item to the toolbar
    [toolBar setItems:@[bbi]
    //this is the inputAccessoryView for BNRDetailViewController
    return toolBar;

- (void)doneEdit:(id)sender
    // since we don't know which text field is the first responder when the
    // done button is pressed, send the message to each
    [self.valueField resignFirstResponder];
    [self.serialNumberField resignFirstResponder];
    [self.nameField resignFirstResponder];
    [self.dateField resignFirstResponder];