0

如何以编程方式在键盘上制作一个带有下一个和上一个的工具栏,以在可编辑字段(Textfield、Textarea、Datepicker、Pikerview)之间导航?

4

2 回答 2

0

https://github.com/simonbs/BSKeyboardControls

像这样编辑文本字段时,此控件可以在键盘上方显示工具栏

在此处输入图像描述

于 2013-04-19T15:42:19.343 回答
0
UIBarButtonItem *prevButton = [[UIBarButtonItem alloc] initWithTitle:@"Prev" style:UIBarButtonItemStyleBordered target:self action:@selector(prevButtonPressed:)];    
UIBarButtonItem *nextButton = [[UIBarButtonItem alloc] initWithTitle:@"Next" style:UIBarButtonItemStyleBordered target:self action:@selector(nextButtonPressed:)];
UIBarButtonItem *flexibleSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(doneButtonPressed:)]

UIToolbar *toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
toolbar.barStyle = UIBarStyleBlackTranslucent;
[toolbar setItems:@[prevButton, nextButton, flexibleSpace, doneButton]];

UITextView *textView = [[UITextView alloc] inithWithFrame:CGRectMake(x, y, width, height)];
textView.inputAccessoryView = toolbar;

您可以使用 aUISegmentedControl创建类似于 @adali 发布的 Prev/Next 效果

于 2013-04-19T15:49:52.087 回答