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