我有一個帶有三個選項的標籤欄,當我嘗試轉到配置文件頁面時,底部的標籤欄被我編程添加的集合視圖所覆蓋。如何確定標籤欄不在此集合中?集合視圖覆蓋標籤欄
這裏是ProfilePageVC:
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(true)
let flowLayout = UICollectionViewFlowLayout()
let collectionView = UICollectionView(frame: self.view.bounds, collectionViewLayout: flowLayout)
collectionView.register(UICollectionViewCell.self, forCellWithReuseIdentifier: "collectionCell")
collectionView.delegate = self
collectionView.dataSource = self
collectionView.backgroundColor = UIColor.cyan
// self.lowerView.addSubview(collectionView)
self.lowerView.insertSubview(collectionView, belowSubview: self.view)
self.reloadInputViews()
}
這裏就是我的標籤欄的代碼是(這是在剛剛常規默認VC)
class ViewController: UIViewController {
@IBOutlet weak var contentView: UIView!
var homeVC : UIViewController!
var testVC : UIViewController!
var profileVC : UIViewController!
var viewControllers : [UIViewController]!
//What tab we are pressing
var selectedVC : Int = 0
override func viewDidLoad() {
super.viewDidLoad()
let storyboard = UIStoryboard(name: "Main", bundle: nil)
homeVC = storyboard.instantiateViewController(withIdentifier: "HomePage")
testVC = storyboard.instantiateViewController(withIdentifier: "RecordPage")
profileVC = storyboard.instantiateViewController(withIdentifier: "ProfilePage")
viewControllers = [homeVC, testVC, profileVC]
buttons[selectedVC].isSelected = true
hasPressedTab(buttons[selectedVC])
}
@IBOutlet var buttons: [UIButton]!
@IBAction func hasPressedTab(_ sender: UIButton) {
let previousVC = selectedVC
selectedVC = sender.tag
buttons[previousVC].isSelected = false
let previousIndex = viewControllers[previousVC]
//removes from previous VC
previousIndex.willMove(toParentViewController: nil)
previousIndex.view.removeFromSuperview()
previousIndex.removeFromParentViewController()
//accesses current button selected
sender.isSelected = true
let vc = viewControllers[selectedVC]
addChildViewController(vc)
//addjusts size of VC to match the added contentView
vc.view.frame = contentView.bounds
contentView.addSubview(vc.view)
vc.didMove(toParentViewController: self)
}
下面是說明問題的圖像:
棕褐色區域是較低視圖
帶出集合視圖作爲子視圖: https://ibb.co/gH2dWF
用的CollectionView作爲一個子視圖: https://ibb.co/jWh1ka
爲什麼符文的服務器上後的iOS問題bruh – Jire