2014-07-02 48 views
1

我正在開發iPhone應用程序,其中我卡在一點。searchBarTextDidBeginEditing委託方法再次調用返回按鈕點擊

我有一個viewController與導航欄隱藏和搜索欄在頁面的中心。

當用戶點擊搜索條searchBarTextDidBeginEditing方法被解僱。

此後在文本更改搜索欄textDidChange方法我在桌面視圖加載實時數據和點擊tableview我導航到其他頁面導航欄非隱藏。

現在,當我再次按下按鈕時,我來到這裏的搜索頁面searchBarTextDidBeginEditing方法再次被解僱。

爲什麼這種方法在背壓時被再次調用?

請幫助和提前致謝。

回答

5

SearcBarTextDidBeginEditing叫由於搜索顯示控制器仍處於工作模式,

在你的TableView委託方法,

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ 

    [self.view endEditing:YES]; 
    [self.searchDisplayController.searchBar resignFirstResponder]; 


    // Set Navigation 
} 

並在同一個班級,在視圖就會出現SET,

-(void)viewWillAppear:(BOOL)animated{ 

    self.searchDisplayController.Active = NO; 

} 

希望這會幫助你!

+0

精湛的答案夥計...它的工作 – Krunal

+0

如果它可以幫助你,那麼你可以接受它作爲正確的參考其他人。 –

1

我認爲UITextField在您導航時會將注意力集中在自身上。

嘗試[textField resignFirstResponder]當你點擊你的tableView導航。

相關問題