Do you want to get the height of the width when rotating the device or when starting the application in landscape mode?
If you rotate the device, you will never get a new width and height in didRotateToInterfaceOrientation.
you need to override the viewWillLayoutSubviews method, where you get the new width and height, and you can check there if the device orientation has changed, you can use the new dimension. Since viewWillLayoutSubviews will be called every time the view changes, so before implementing the function, please keep in mind and read the Apple documentation.
source share