Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

搜索结果布局有问题 #212

Closed
zhaohuang2016 opened this issue Apr 4, 2019 · 1 comment
Closed

搜索结果布局有问题 #212

zhaohuang2016 opened this issue Apr 4, 2019 · 1 comment

Comments

@zhaohuang2016
Copy link

zhaohuang2016 commented Apr 4, 2019

搜索结果超过一屏时,键盘收起状态时,非刘海屏手机最后一个cell有半个cell的高度显示不了,刘海屏手机差不多有一个cell显示不了,demo多加点假数据就能重现
for (int i = 0; i < arc4random_uniform(5) + 30; i++) {
NSString *searchSuggestion = [NSString stringWithFormat:@"Search suggestion %d", i];
[searchSuggestionsM addObject:searchSuggestion];
}

@zhaohuang2016
Copy link
Author

zhaohuang2016 commented Apr 9, 2019

等了几天,作者没回复,所以自己改了,希望能帮到遇到我同样问题的人,我的情况是搜索结果显示的cell是自定义的把源代码替换了,所以布局有问题,如果有同样情况的人可以参考下我的解决代码:
PYSearchSuggestionViewController类的这个方法

  • (void)setSearchSuggestions:(NSArray<NSString *> *)searchSuggestions
    {
    _searchSuggestions = [searchSuggestions copy];

    [self.tableView reloadData];

    /**

    • Adjust the searchSugesstionView when the keyboard changes.
    • more information can see : 键盘存在与否,影响数据的整体显示 #61
      */
      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 - CGRectGetMaxY(self.navigationController.navigationBar.frame), 0))) {
      self.tableView.contentInset = self.originalContentInsetWhenKeyboardHidden;
      }
      self.tableView.contentOffset = CGPointMake(0, -self.tableView.contentInset.top);

    if (@available(iOS 11.0, *))
    {
    UIEdgeInsets contentInsets = self.tableView.adjustedContentInset;
    if (self.keyboardDidShow) {

          self.tableView.contentInset = UIEdgeInsetsMake(-30, 0,-30, 0);
      } else {
          
          CGFloat bottom = isIphoneX == YES ? [[UIApplication sharedApplication] delegate].window.safeAreaInsets.bottom + contentInsets.bottom : contentInsets.bottom;
          self.tableView.contentInset = UIEdgeInsetsMake(-30,0,bottom, 0);
      }
    

    }
    }
    把源代码的最后一行替换成
    if (@available(iOS 11.0, *))
    {
    UIEdgeInsets contentInsets = self.tableView.adjustedContentInset;
    if (self.keyboardDidShow) {

          self.tableView.contentInset = UIEdgeInsetsMake(-30, 0,-30, 0);
      } else {
          
          CGFloat bottom = isIphoneX == YES ? [[UIApplication sharedApplication] delegate].window.safeAreaInsets.bottom + contentInsets.bottom : contentInsets.bottom;
          self.tableView.contentInset = UIEdgeInsetsMake(-30,0,bottom, 0);
      }
    

    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant