当我在SearchController中单击一个用户时,相对的配置文件会显示出来,但是NavigationController下有一个黑条,当我从左向右滑动回到SearchController时,也会出现相同的问题。谁能帮我?谢谢
这是UserProfile代码
class UserProfileVC: UICollectionViewController, UICollectionViewDelegateFlowLayout, UserProfileHeaderDelegate {
override func viewDidLoad() {
super.viewDidLoad()
collectionView?.register(FeedCell.self, forCellWithReuseIdentifier: cellId)
collectionView?.register(UserProfileHeader.self, forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: headerId)
view.addSubview(collectionView)
collectionView.delegate = self
collectionView.dataSource = self
setUpNavigationController()
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
navigationController?.navigationBar.prefersLargeTitles = true
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
navigationController?.navigationBar.prefersLargeTitles = true
}
private func setUpNavigationController() {
navigationController?.navigationBar.barTintColor = UIColor(white: whitePoint, alpha: 1)
navigationController?.navigationBar.isTranslucent = false
navigationController?.navigationBar.tintColor = .black
navigationController?.navigationBar.setValue(true, forKey: "hidesShadow")
navigationController?.navigationBar.prefersLargeTitles = true
}
// MARK: - UICollectionViewFlowLayout
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize {
return CGSize(width: view.frame.width, height: 150)
}
// MARK: - UICollectionView
override func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
let header = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: headerId, for: indexPath) as! UserProfileHeader
header.delegate = self
header.user = self.user
navigationItem.title = user?.name
return header
}
override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell{
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: cellId, for: indexPath) as! FeedCell
cell.post = posts[indexPath.item]
return cell
}
}