gpt4 book ai didi

ios - TableView 单元格在按下 'Back' 后被导航覆盖?

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:11:43 25 4
gpt4 key购买 nike

所以我在导航栏下有一个表格 View ,当用户在搜索栏中输入内容时,它会显示出来。一切似乎都能找到。但是在我推送 View Controller 后,当用户在 TableView 中选择一个单元格,然后从 detailViewController 返回时,我的 TableView 被搞砸了。

• 问题:在我按下 detailViewController 后,tableview 最顶部的单元格被导航栏覆盖。但这不会在一开始就发生。

• 我试过:

   1. Toggled 'Under Top Bars' in the storyboard
2. Check all my constraint

This is how added the tableview onto the subview

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 之前:

enter image description here

从 detailViewController 按下返回按钮后:

The first index is covered by the navigation controller

enter image description here

最佳答案

转到 Storyboard。

选择 ViewController(不是 TableView 或导航 Controller )。

在属性检查器中,取消选中 Adjust Scroll View Insets

关于ios - TableView 单元格在按下 'Back' 后被导航覆盖?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43329515/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com