我想隱藏的UISearchBar大部分時間,只把它當用戶希望它出現。滑動的UISearchBar
我已經把一個UISearchBar放在界面生成器中,並將它隱藏在一個視圖後面,當用戶點擊一個按鈕時,它會調用下面的代碼,我希望它會將搜索欄放到前面並滑動鍵盤來查看。但它不....
- (IBAction)search:(id)sender
{
[mySearchBar performSelector:@selector(searchBarTextDidBeginEditing:)];
}
任何人都知道如何通過代碼激活UISearchBar?
謝謝。
感謝您的回覆。我只是發佈完整的代碼,以防某人感興趣
- (IBAction)search:(id)sender
{
mySearchBar.hidden = NO;
[mySearchBar becomeFirstResponder];
}
#pragma mark UISearchBarDelegate delegate methods
// called when keyboard search button pressed
- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar
{
mySearchBar.hidden = YES;
[mySearchBar resignFirstResponder];
// Do something with the mySearchBar.text
}
// called when cancel button pressed
- (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar
{
mySearchBar.hidden = YES;
[mySearchBar resignFirstResponder];
}
這是很棒的提示,歡呼聲 – Dan 2008-10-21 12:49:56