table 下面的额外白色 space 使用搜索栏查看 Swift Xcode
Extra white space below table view using search bar Swift Xcode
我有一个 UITableView
,当我向下滚动到底部时,底部有一个额外的白色 space 几乎是一个完整单元格的大小,
在那里 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
我发现如果我取消搜索条形码,table 视图外观一切正常,当我带回额外白色的代码时 space回来了。
- 我尝试将内容插入值更改为 none 但没有成功。
- 我尝试从
ViewController
中勾选调整滚动视图插图
- 我检查了约束以确保它们都很好。
我怎样才能让白色 space 消失?
在 故事板 中为您的 UIViewController
检查以下内容:
延伸边
1. 在不透明条下
2. 底栏下方
您可以尝试两种方法来解决这个问题:
第一名:
tableView.contentInset = UIEdgeInsetsMake(0, 0, -29, 0);
第二名:
tableView.tableFooterView = UIView(frame: CGRect(x: 0, y: 0, width: 0, height: CGFloat.leastNonzeroMagnitude))
或者只是:
tableView.tableFooterView = UIView()
我有一个 UITableView
,当我向下滚动到底部时,底部有一个额外的白色 space 几乎是一个完整单元格的大小,
在那里 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
我发现如果我取消搜索条形码,table 视图外观一切正常,当我带回额外白色的代码时 space回来了。
- 我尝试将内容插入值更改为 none 但没有成功。
- 我尝试从
ViewController
中勾选调整滚动视图插图
- 我检查了约束以确保它们都很好。
我怎样才能让白色 space 消失?
在 故事板 中为您的 UIViewController
检查以下内容:
延伸边
1. 在不透明条下
2. 底栏下方
您可以尝试两种方法来解决这个问题: 第一名:
tableView.contentInset = UIEdgeInsetsMake(0, 0, -29, 0);
第二名:
tableView.tableFooterView = UIView(frame: CGRect(x: 0, y: 0, width: 0, height: CGFloat.leastNonzeroMagnitude))
或者只是:
tableView.tableFooterView = UIView()