2
所以我有一个导航栏下的tableview,当用户在搜索栏中输入内容时会显示出来。一切似乎都可以发现。但是当我推送一个视图控制器,当用户在tableview中选择一个单元格,然后从detailViewController返回时,我的tableview就搞砸了。按下“返回”后,TableView单元格被导航覆盖?
•问题:在按下detailViewController后,tableview的最顶端单元格被导航栏覆盖。但是这一开始并没有发生。
•我已经试过:
1. Toggled 'Under Top Bars' in the storyboard
2. Check all my constraint
这是实现代码如下如何添加到子视图
func updateSearchResults(for searchController: UISearchController) {
// When the user is typing
if let searchText = searchController.searchBar.text, !searchText.isEmpty {
// add the tableview onto the subview
view.addSubview(tableView)
self.searchController.dimsBackgroundDuringPresentation = false
// filter the username array, to match the text in the search bar
filteredUsernames = unfilterdUsernames.filter({ (username) -> Bool in
return username.lowercased().contains(searchText.lowercased())
})
if let usernames = filteredUsernames {
getUsersFromUsernames(usernames: usernames, completion: { (users) in
self.filteredUsers = users
})
}
// else, the user is not typing anything. Remove the tableview from the subview
} else {
self.searchController.dimsBackgroundDuringPresentation = false
tableView.removeFromSuperview()
filteredUsernames = unfilterdUsernames
}
// reload tableview data
tableView.reloadData()
}
我这是怎么搬进detailViewController:
tableView(_ tableView:UITableView, didSelectRowAt indexPath:IndexPath)
// the profile view that I want to display, after the user select one of the tableViewCell
let profileController = UIStoryboard(name: "Profile", bundle: nil).instantiateViewController(withIdentifier: "profile") as? ProfileCollectionViewController
// user is the value that I want to transfer to the profileController
// which user from the indexPath in tableView
if let user = filteredUsers?[indexPath.row] {
userToPass = user
// set the delegate to self
profileController?.userDataDelegate = self
// push a navigationController to profileController
self.navigationController?.pushViewController(profileController!, animated: true)
才去detailViewController:
后从detailViewController按下后退按钮:
第一个指数是由覆盖导航控制器
行是否真的存在并覆盖?或者“babi”是桌子上唯一的一排?换句话说,当你从“个人资料”视图“回来”时,你可以拉下桌子看到最上面一排(包含“jajang”)吗? – DonMag
@DonMag是的,最上面的一行是'jajang',但是最上面一行被导航栏覆盖(在我从详细视图中按下按钮之后)。这意味着我仍然可以向下滚动。一开始并不像那样。 –
好的 - 当你向下滚动,然后松开你的手指......最上面的一行*保持可见?或者在导航栏下面“快速恢复”? – DonMag