IGAutoCompletionToolbar創(chuàng)建具有自動(dòng)完成功能的文本輸入框
IGAutoCompletionToolbar 是 UICollectionView 的子類用于創(chuàng)建具有自動(dòng)完成功能的文本輸入框。自動(dòng)完成的列表顯示在輸入鍵盤之上。類似各種輸入法。
要求
iOS 7或更高版本(帶ARC)。
安裝
如果使用的是 CocoaPods,請(qǐng)將“ IGAutoCompletionToolbar”添加到 Podfile 中:
pod 'IGAutoCompletionToolbar', '~> 0.2.1'
否則,下載項(xiàng)目并在 IGAutoCompletionToolbar / * 和 'QuartzCore' 框架下將文件添加到你的項(xiàng)目。
用法
在應(yīng)用程序中導(dǎo)入 IGAutoCompletionToolbar:
#import "IGAutoCompletionToolbar.h"
然后創(chuàng)建工具欄,并將其與文本字段連接:
// Create the toolbar
IGAutoCompletionToolbar* toolbar = [[IGAutoCompletionToolbar alloc] initWithFrame:CGRectMake(0,0,320,44)];
// set auto complete items
toolbar.items = @[@"Apple", @"Banana", @"Blueberry", @"Grape", @"Pineapple", @"Orange", @"Pear"];
// setup the delegate
toolbar.toolbarDelegate = self;
// setup the text field to be used
toolbar.textField = self.textfield;
// set the toolbar as the input accessory view of the textfield
self.textfield.inputAccessoryView = toolbar;評(píng)論
圖片
表情
