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;

How to right or center align the UIToolBar items

create  buttons like this 
UIBarButtonItem *flexibleSpace = [[UIBarButtonItem alloc] 
              target:nil action:nil];

Add  UIBarButtonSystemItemFlexibleSpace items to your toolbar, to the left and right of your items OR left to get the center align OR right align

Wednesday, September 1, 2010