1
我正在做一個選項卡欄應用程序,我有一個搜索欄的視圖,我想調用一個新的視圖,當用戶點擊ipod/iphone鍵盤的搜索按鈕時在tableview上顯示結果。如何在「搜索欄」上搜索後調用新視圖來顯示結果?
在這裏,你有幾個mock-ups釐清思路:
謝謝!
我正在做一個選項卡欄應用程序,我有一個搜索欄的視圖,我想調用一個新的視圖,當用戶點擊ipod/iphone鍵盤的搜索按鈕時在tableview上顯示結果。如何在「搜索欄」上搜索後調用新視圖來顯示結果?
在這裏,你有幾個mock-ups釐清思路:
謝謝!
UISearchBar
類有一個委託類UISearchBarDelegate
。其方法searchBarSearchButtonClicked
:在用戶單擊鍵盤上的搜索按鈕時調用。在此委託方法中,您可以將新視圖推送到導航堆棧或使用任何您想要的顯示邏輯。
-(void) loadView{
// set up your view ...
// set up your search bar
UISearchBar *searchBar = [[[UISearchBar alloc] init] autorelease];
[searchBar setDelegate:self];
}
- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar
{
//push your view controller onto the nav stack or whatever
}