2

私はこれを持っていますがUISearchDisplayController、これまでのところsearchresulttableview、誰かがUISearchBar. ボタンにこのタスクを実行させる方法はありますか? 受け取った回答に感謝します。

4

3 に答える 3

3

ボタンセレクター内で試しました[searchDisplayController.searchbar becomeFirstResponder]か?

于 2013-11-04T23:42:43.243 に答える
2

Look at the docs for UISearchDisplayController. There is an active property and a setActive:animated: method.

Have your button action call this:

[theSearchController setActive:YES animated:YES];
于 2013-11-04T23:52:28.953 に答える
1

のようにUISearchBar拡張されるため、検索バーを呼び出すだけでフォーカスを当てることができます。UIResponderUITextFieldbecomeFirstResponder

[button addTarget:self action:@selector(clickedSearchBar) forControlEvents:UIControlEventTouchUpInside];

- (void)clickedSearchBar {
    [searchDisplayController.searchbar becomeFirstResponder];
}
于 2013-11-04T23:44:23.927 に答える