Created
December 17, 2012 01:20
-
-
Save YoonjaeYoo/4315075 to your computer and use it in GitHub Desktop.
Input accessory view for UITextField or UITextView that has previous, next and done button.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UIToolbar *toolBar = [[UIToolbar alloc] init]; | |
toolBar.barStyle = UIBarStyleBlack; | |
toolBar.translucent = YES; | |
[toolBar sizeToFit]; | |
textField.inputAccessoryView = toolBar; | |
[toolBar release]; | |
UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:NSLocalizedString(@"Previous", nil), NSLocalizedString(@"Next", nil), nil]]; | |
segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar; | |
segmentedControl.momentary = YES; | |
[segmentedControl addTarget:self action:@selector(textFieldSegmentedControlValueChanged:) forControlEvents:UIControlEventValueChanged]; | |
UIBarButtonItem *previousNextButton = [[UIBarButtonItem alloc] initWithCustomView:segmentedControl]; | |
[segmentedControl release]; | |
UIBarButtonItem *space = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil]; | |
UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(textFieldDoneButtonClicked:)]; | |
toolBar.items = [NSArray arrayWithObjects:previousNextButton, space, doneButton, nil]; | |
[previousNextButton release]; | |
[space release]; | |
[doneButton release]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment