دنبال کننده ها

۱۳۹۶ اسفند ۲۴, پنجشنبه

ios - UITabBar change view hierarchy after rotating process. (or changes its position in view hierarchy)

[ad_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?




[ad_2]

لینک منبع