views:

50

answers:

1

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.

+2  A: 

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

Rudiger