我正在开发 iPhone 应用程序,我曾一度陷入困境。
我有一个隐藏导航栏的 viewController,搜索栏位于页面中央。
当用户点击 searchBar searchBarTextDidBeginEditing
方法被解雇。
在此之后搜索栏的文本更改 textDidChange
方法我在 tableview 中加载实时数据,点击 tableview 我导航到其他页面,导航栏不隐藏。
现在,当我再次按下返回按钮时,我来到这里的搜索页面 searchBarTextDidBeginEditing
方法再次被解雇。
为什么在后按时再次调用此方法?
请提前帮助和感谢。
最佳答案
您的 SearcBarTextDidBeginEditing
由于您的搜索显示 Controller 仍处于事件模式而调用,
在您的 TableView 委托(delegate)方法中,
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
[self.view endEditing:YES];
[self.searchDisplayController.searchBar resignFirstResponder];
// Set Navigation
}
并且在同一个类中,在 View 中会出现 SET,
-(void)viewWillAppear:(BOOL)animated{
self.searchDisplayController.Active = NO;
}
希望对你有帮助!
关于ios - 在单击后退按钮时再次调用 searchBarTextDidBeginEditing 委托(delegate)方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24530084/