diff --git a/PYSearch/PYSearchSuggestionViewController.m b/PYSearch/PYSearchSuggestionViewController.m index 3b02e44..b7eb406 100644 --- a/PYSearch/PYSearchSuggestionViewController.m +++ b/PYSearch/PYSearchSuggestionViewController.m @@ -77,9 +77,9 @@ - (void)setSearchSuggestions:(NSArray *)searchSuggestions * Adjust the searchSugesstionView when the keyboard changes. * more information can see : https://github.com/iphone5solo/PYSearch/issues/61 */ - if (self.keyboardDidShow && !UIEdgeInsetsEqualToEdgeInsets(self.originalContentInsetWhenKeyboardShow, UIEdgeInsetsZero) && !UIEdgeInsetsEqualToEdgeInsets(self.originalContentInsetWhenKeyboardShow, UIEdgeInsetsMake(-30, 0, 30 - 64, 0))) { + if (self.keyboardDidShow && !UIEdgeInsetsEqualToEdgeInsets(self.originalContentInsetWhenKeyboardShow, UIEdgeInsetsZero) && !UIEdgeInsetsEqualToEdgeInsets(self.originalContentInsetWhenKeyboardShow, UIEdgeInsetsMake(-30, 0, 30 - CGRectGetMaxY(self.navigationController.navigationBar.frame), 0))) { self.tableView.contentInset = self.originalContentInsetWhenKeyboardShow; - } else if (!self.keyboardDidShow && !UIEdgeInsetsEqualToEdgeInsets(self.originalContentInsetWhenKeyboardHidden, UIEdgeInsetsZero) && !UIEdgeInsetsEqualToEdgeInsets(self.originalContentInsetWhenKeyboardHidden, UIEdgeInsetsMake(-30, 0, 30 - 64, 0))) { + } else if (!self.keyboardDidShow && !UIEdgeInsetsEqualToEdgeInsets(self.originalContentInsetWhenKeyboardHidden, UIEdgeInsetsZero) && !UIEdgeInsetsEqualToEdgeInsets(self.originalContentInsetWhenKeyboardHidden, UIEdgeInsetsMake(-30, 0, 30 - CGRectGetMaxY(self.navigationController.navigationBar.frame), 0))) { self.tableView.contentInset = self.originalContentInsetWhenKeyboardHidden; } self.tableView.contentOffset = CGPointMake(0, -self.tableView.contentInset.top); diff --git a/PYSearch/PYSearchViewController.m b/PYSearch/PYSearchViewController.m index db975a6..e5ead7e 100755 --- a/PYSearch/PYSearchViewController.m +++ b/PYSearch/PYSearchViewController.m @@ -155,7 +155,7 @@ - (void)viewWillAppear:(BOOL)animated // Adjust the view according to the `navigationBar.translucent` if (NO == self.navigationController.navigationBar.translucent) { self.baseSearchTableView.contentInset = UIEdgeInsetsMake(0, 0, self.view.py_y, 0); - self.searchSuggestionVC.view.frame = CGRectMake(0, 64 - self.view.py_y, self.view.py_width, self.view.py_height + self.view.py_y); + self.searchSuggestionVC.view.frame = CGRectMake(0, CGRectGetMaxY(self.navigationController.navigationBar.frame) - self.view.py_y, self.view.py_width, self.view.py_height + self.view.py_y); if (!self.navigationController.navigationBar.barTintColor) { self.navigationController.navigationBar.barTintColor = PYSEARCH_COLOR(249, 249, 249); } @@ -167,7 +167,6 @@ - (void)viewWillDisappear:(BOOL)animated [super viewWillDisappear:animated]; [self.searchBar resignFirstResponder]; - } - (void)dealloc @@ -231,7 +230,7 @@ - (PYSearchSuggestionViewController *)searchSuggestionVC [_swSelf searchBarSearchButtonClicked:_swSelf.searchBar]; } }; - searchSuggestionVC.view.frame = CGRectMake(0, 64, PYScreenW, PYScreenH); + searchSuggestionVC.view.frame = CGRectMake(0, CGRectGetMaxY(self.navigationController.navigationBar.frame), PYScreenW, PYScreenH); searchSuggestionVC.view.backgroundColor = self.baseSearchTableView.backgroundColor; searchSuggestionVC.view.hidden = YES; _searchSuggestionView = (UITableView *)searchSuggestionVC.view; @@ -998,7 +997,7 @@ - (void)handleSearchResultShow [self.view addSubview:self.searchResultController.view]; [self addChildViewController:self.searchResultController]; self.searchResultController.view.hidden = NO; - self.searchResultController.view.py_y = NO == self.navigationController.navigationBar.translucent ? 0 : 64; + self.searchResultController.view.py_y = NO == self.navigationController.navigationBar.translucent ? 0 : CGRectGetMaxY(self.navigationController.navigationBar.frame); self.searchResultController.view.py_height = self.view.py_height - self.searchResultController.view.py_y; self.searchSuggestionVC.view.hidden = YES; } else {