문제

I've looked all over the net trying to figure out how to get the bounds based on orientation. The notifications are working fine but I'm getting the bounds of the view via:

CGRect cgRect = self.view.bounds;

which returns {0, 0}, {320, 460} which is correct but when the device is rotated it returns the same CGRect, where I was expecting completely different values.

I have tried using the property autoresizeSubviews on self.view but this doesn't change it.

Im doing all of this in code btw, no nibs so the navigation bar isn't moving either. I'm just using the notification UIDeviceOrientationDidChangeNotification which responds correctly.

도움이 되었습니까?

해결책

Found the best way to sort this out is register for device orientation change notifications and then:

UIDeviceOrientation deviceOrientation = [UIDevice currentDevice].orientation;

Will return which orientation the device is in. From this you can the appropriate calculations to display the view

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top