UISearchBar文本字段在从详细信息视图返回后无法编辑,但是选项选项也可以在交叉按钮工作时可见。
使用以下代码
@property (weak, nonatomic) IBOutlet UISearchBar *searchBar;
- (void) viewWillAppear:(BOOL)animated {
[super viewWillAppear:YES];
[self performSelector:@selector(showKeyboard) withObject:nil afterDelay:0.1];
}
- (void)showKeyboard {
[self.searchBar becomeFirstResponder];
}
哪个是第一次工作但回来时却无法正常工作。但showKeyboard方法的断点正在运行。
此搜索用于两个不同的部分,代码就是这样 -
UINavigationController *navController =self.navigationController;
TPTabBarController *tabbar = nil;
if([navController.presentingViewController isKindOfClass:[TPTabBarController class]]){
tabbar = (TPTabBarController *)navController.presentingViewController;
}else{
NSLog(@"Failed to get tabbar in TPBookViewController. It is nil.");
}
if(tabbar != nil && tabbar.searchNavigationController != nil){
if(tabbar.searchNavigationController.viewControllers.count == 2){
//current view is SearchResultViewController
SearchResultViewController *searchResultViewController = (SearchResultViewController*)tabbar.searchNavigationController.viewControllers[1];
[searchResultViewController reloadDataAndLocateToPage:self.currentPage manual:_currentManual];
}
[self presentViewController:tabbar.searchNavigationController animated:YES completion:nil];
}
在一个部分正在工作,但在另一个视图控制器中它无法正常工作