0

tableView があり、tableView に検索機能を適用したいと考えています。そのためには textField と search Button が必要ですが、これらをプログラムで作成する方法がわかりません。この 2 つのツールの作成方法を教えてください。

ありがとう。

4

3 に答える 3

1

非同期スクロールバーの例について説明している次のリンクを試してください

http://blog.patrickcrosby.com/2010/04/27/iphone-ipad-uisearchbar-uisearchdisplaycontroller-asynchronous-example.html

ただし、前の投稿 UISearchBarサンプルコードを参照することもできます

入力時に結果を実装および取得するその他の方法については、applesのドキュメントにアクセスし、UISearchBarDelegateプロトコルメソッドを参照してください。

于 2011-09-24T17:29:00.703 に答える
0

UITextFieldUIButtonのドキュメントは次のとおりです。テキスト フィールドとボタンの両方を組み込んだUISearchBarも便利です。

ビューをテーブル ビューのヘッダー ビューに追加します。

于 2011-09-24T07:19:42.663 に答える
0

テーブル delegate がありますtableview:cellForRowAtIndexPath。このデリゲートに次のコードを追加します。

//Suppose you want to add textfield and button at the first row
if(indexPath.Row == 0)
{
         UITextField *txtSearch = [UITextField alloc] initWithFrame:CGRectMake(0,0,150,35)];
         UIButton *btnSearch = [UIButton buttonWithType:UIButtoTypeCustom];
         btnSearch.frame = CGRectMake(160,0,50,35);

         [[cell contentView] addSubView:txtSearch];
         [[cell contentView] addSubView:btnSearch];
}

また、ボタンのようなイベントを追加することもできます

[btnSearch addTarget:self action:@selector(eventName) forControlEvents:UIControlEventTouchUpInside];

ありがとう

于 2011-09-24T07:19:48.063 に答える