Skip to content

Commit

Permalink
Adapted iPhoneX & Fixed #120
Browse files Browse the repository at this point in the history
Adapted iPhoneX & Fixed #120
  • Loading branch information
ko1o committed Oct 11, 2017
1 parent b48c604 commit 87775cd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
4 changes: 2 additions & 2 deletions PYSearch/PYSearchSuggestionViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ - (void)setSearchSuggestions:(NSArray<NSString *> *)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);
Expand Down
7 changes: 3 additions & 4 deletions PYSearch/PYSearchViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -167,7 +167,6 @@ - (void)viewWillDisappear:(BOOL)animated
[super viewWillDisappear:animated];

[self.searchBar resignFirstResponder];

}

- (void)dealloc
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 87775cd

Please sign in to comment.