Closed zhaohuang2016 closed 5 years ago
等了几天,作者没回复,所以自己改了,希望能帮到遇到我同样问题的人,我的情况是搜索结果显示的cell是自定义的把源代码替换了,所以布局有问题,如果有同样情况的人可以参考下我的解决代码: PYSearchSuggestionViewController类的这个方法
(void)setSearchSuggestions:(NSArray<NSString > )searchSuggestions { _searchSuggestions = [searchSuggestions copy];
[self.tableView reloadData];
/**
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);
}
}
搜索结果超过一屏时,键盘收起状态时,非刘海屏手机最后一个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]; }