使用搜索栏Swift Xcode在表格视图下方留出额外的空白区域

时间:2018-05-16 07:11:22

标签: ios swift xcode tableview uisearchbar

我有一个UITableView,当我向下滚动到底部时,底部有一个额外的白色空间,大小相当于一个完整的单元格, 在ViewController我有一个搜索栏,我这样添加:

ViewDidLoad

searchController.searchResultsUpdater = self
searchController.hidesNavigationBarDuringPresentation = false
searchController.dimsBackgroundDuringPresentation = false
searchController.searchBar.sizeToFit()
searchController.searchBar.setValue("ביטול", forKey:"_cancelButtonText")
searchController.searchBar.placeholder = "חפש כאן..."
let searchTextField = searchController.searchBar.value(forKey: "_searchField") as! UITextField
searchTextField.textAlignment = NSTextAlignment.right

if #available(iOS 9.0, *) {
    searchController.searchBar.semanticContentAttribute = .forceRightToLeft
}
let attributes = [NSAttributedStringKey.foregroundColor : UIColor.white]
if #available(iOS 9.0, *) {
    UIBarButtonItem.appearance(whenContainedInInstancesOf: [UISearchBar.self]).setTitleTextAttributes(attributes, for: .normal)
}
tableOrder.tableHeaderView = searchController.searchBar

我发现,如果我取消搜索条形码,桌面视图外观都很好,当我带回代码时会有额外的空白区域回来。

  • 我尝试将内容insets值更改为none,但没有成功。
  • 我尝试从ViewController
  • 尝试关闭调整滚动视图插图
  • 我检查了约束条件以确保它们都很好。

如何让白色空间消失?

2 个答案:

答案 0 :(得分:0)

情节提要中检查 <!-- Comments cards --> <div class="container"> <div ng-repeat="($index,comment) in comments" style="margin-top:50px;"> <div class="md-title">Comment: {{ $index + 1 }}</div> <br> <md-card> <md-content layout="row"> <div class="flex-90"> <md-card-content class="md-title"> {{comment.body}} </md-card-content> <md-chips> <md-chip> {{comment.email}} </md-chip> </md-chips> </div> <div class="flex" layout="row" layout-align="end start"> <md-button class="md-icon-button" ng-click="editComment(comment)"> <md-icon>edit</md-icon> </md-button> <md-button class="md-icon-button" ng-click="deleteComment($event, comment)"> <md-icon>clear</md-icon> </md-button> </div> </md-content> </md-card> </div> </div>的以下内容:
延伸边缘
1. Under Opaque Bars
2. Under Bottom Bars

enter image description here

答案 1 :(得分:0)

您可以尝试2种方法来解决此问题: 1st:

tableView.contentInset = UIEdgeInsetsMake(0, 0, -29, 0);

第二:

tableView.tableFooterView = UIView(frame: CGRect(x: 0, y: 0, width: 0, height: CGFloat.leastNonzeroMagnitude))

或者只是:

tableView.tableFooterView = UIView()