Friday, September 24, 2010

Add UIToolBar on top of Keyboard

UIToolbar *boolbar = [UIToolbar new];
boolbar.barStyle = UIBarStyleDefault;
[boolbar sizeToFit];
  
  
UIBarButtonItem *cancelleftBarButton =[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(buttonClicked:)];
NSArray *array = [NSArray arrayWithObjects:cancelleftBarButton, nil];
[cancelleftBarButton release];
[boolbar setItems:array];
  
myTextFieldorTextView.inputAccessoryView = boolbar;

4 comments:

  1. The code fails when you click the button... am i missing something?

    ReplyDelete
  2. The button has on click method "buttonClicked" . So you must implement this method and do resignResponder for the textfield object
    Hope this helps
    Thanks

    ReplyDelete
  3. You saved my life!!!! Thank you!!!

    ReplyDelete