我有一个带有三个选项的标签栏,当我尝试转到配置文件页面时,底部的标签栏被我编程添加的集合视图所覆盖。如何确定标签栏不在此集合中?集合视图覆盖标签栏
这里是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