现在的位置: 首页 > 综合 > 正文

Creating a combo box for the iPhone(思路)

2012年01月08日 ⁄ 综合 ⁄ 共 670字 ⁄ 字号 评论关闭

In a view controller you have a UITextField and a UITableView. Assign the view controller to be the delegate of the both controls, plus the data source of the table.

Implement the UITextField delegate methodtextField:shouldChangeCharactersInRange:replacementString: in your controller. This intercepts the changes as they are being typed in your text field. In this method, iterate through your list of possible options and store the matches in an NSMutableArray instance variable on your view controller. Then call [myTableView reloadData].

Have your table cells generated from the array of matches you previously stored.

It should be pretty straightforward and shouldn't take much code at all beyond a few delegate methods to get working.

 

UITextField + UIButton + UITableView即可实现。

抱歉!评论已关闭.