1

I have a view with several subviews (with only one peculiarity I added tabBar as a subview to a view of VC)

   super.viewDidLoad()
   view.addSubview((tabBarController?.tabBar)!)
    view.addSubview(collectionView)
    view.addSubview(pageControl)

    view.addSubview(skipButton)
    view.addSubview(nextButton)
    print( view.constraints)

    nextButton.anchorWithConstantsToTop(view.topAnchor, left: nil, bottom: nil, right:
    view.rightAnchor, topConstant: 16, leftConstant: 0, bottomConstant: 0, rightConstant: 0)
    nextButtonTopAnchor = nextButton.topAnchor.constraint(equalTo: view.topAnchor, constant: 0)
    nextButton.heightAnchor.constraint(equalToConstant: 50).isActive = true
    nextButton.widthAnchor.constraint(equalToConstant: 60).isActive = true
    skipButton.anchorWithConstantsToTop(view.topAnchor, left: view.leftAnchor, bottom: nil, right: nil, topConstant: 16, leftConstant: 0, bottomConstant: 0, rightConstant: 0)
    skipButton.heightAnchor.constraint(equalToConstant: 50).isActive = true
    skipButton.widthAnchor.constraint(equalToConstant: 60).isActive = true


     pageControl.anchorWithConstantsToTop(nil, left: view.leftAnchor, bottom: tabBarController?.tabBar.topAnchor, right: view.rightAnchor, topConstant: 0, leftConstant: 28, bottomConstant: 0, rightConstant: 30)
    pageControl.heightAnchor.constraint(equalToConstant: 121).isActive = true



    collectionView.anchorToTop(view.topAnchor, left: view.leftAnchor, bottom: view.bottomAnchor, right: view.rightAnchor)

Something bizarre (for me) happend when I rotate device. 1) in portrait orientation everything ok. All subviews stands in hierarchy chain as they are supposed to. (especially UITabBar)enter image description here but then after rotation process to landscape orientation UITabbar separates from UIView, and of course constraint regarding to pageControl bottom: tabBarController?.tabBar.topAnchor is vanished. enter image description here Why is it happens?

Ninja
  • 309
  • 7
  • 26
  • This looks like an odd approach... Why not use the built-in TabBar? Are you setting constraints on the `tabBar` you're manually adding to the view? – DonMag Mar 15 '18 at 12:44

0 Answers0