I am trying to get height of the toolbar
which is provided by NavigationControleller
, not added manually. I am getting a height of 44 in landscape and 32 in portrait when it is clearly the opposite of what I see/get on screen!
Here is the relevant part of my function:
// Update the layout based on the orientation
override func viewWillTransitionToSize(size: CGSize, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator) {
// Add the constraints based on the orientation
if UIDevice.currentDevice().orientation.isLandscape.boolValue {
println("Landscape")
} else {
println("Portrait")
}
let toolbarHeight = self.navigationController!.toolbar.frame.size.height
let toolbarIntrinsicHeight = self.navigationController!.toolbar.intrinsicContentSize().height
println("height = \(toolbarHeight)")
println("Intrinsic height = \(toolbarIntrinsicHeight)")
println("-------------")
}
This is the console output:
Landscape
height = 44.0
Intrinsic height = 44.0
-------------
Portrait
height = 32.0
Intrinsic height = 32.0
-------------
What is wrong? What is the correct way to do this?
Note: I am using simulators iPhone 5s and iPhone 6. iPhone 6 plus has height 44 in both orientations.