iHorse
iHorse

Reputation: 595

How to show the “Previous/Next/Done” bar with a UITextView

i've seen a "Previous/Next/Done" bar above the keyboard when entering text in a webview on an iPhone. i want to use this built in bar in an app that i'm making in conjunction with a UITextView. i have seen a very similar looking bar above the keyboard in several apps. my guess is this is either some hand made bar that just looks like the bar i want or the programmer figured out a way to show the actual bar. assuming its the actual bar and not a hand made bar how do you get it to display?

Upvotes: 3

Views: 3509

Answers (3)

Create this method and call it on ViewWillLoad:

        - (void) keyboardToolbarSetup
{
    if(self.keyboardToolbar==nil)
        {
        self.keyboardToolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 44)];

        UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc] initWithTitle:@"Cancel" style:UIBarButtonItemStylePlain target:self action:@selector(anyAction)];

        UIBarButtonItem *extraSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];

        UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithTitle:@"Done" style:UIBarButtonItemStyleDone target:self action:@selector(anyOtherAction)];


        NSArray *toolbarButtons = [[NSArray alloc]initWithObjects:cancelButton,extraSpace,doneButton, nil];

        [self.keyboardToolbar setItems:toolbarButtons];

        self.myTextView.inputAccessoryView=self.keyboardToolbar;
        }
}

Upvotes: 1

0xced
0xced

Reputation: 26583

I wrote XCDFormInputAccessoryView which is an input accessory view with previous/next/done buttons.

Upvotes: 3

Can Berk Güder
Can Berk Güder

Reputation: 113370

There's no built-in Prev/Next/Done bar, you have to create it yourself.

SEE ALSO:

Upvotes: 3

Related Questions