You check the frame size and borders too quickly.
Instead, check them after rotation:
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { NSLog(@"Bounds %@", NSStringFromCGRect(self.view.bounds)); NSLog(@"Frame %@", NSStringFromCGRect(self.view.frame)); }
(Pay attention to my use of NSStringFromCGRect - convenient!)
This leads to the output:
Bounds {{0, 0}, {1024, 748}} Frame {{0, 0}, {748, 1024}}
So, in this release, the frame is “wrong,” but borders are what you expect. In fact, the frame is actually not the same as the way the frame calculations → are performed. Therefore, you need to access the borders.
See also maybe. Do I have the correct understanding of frames and borders in UIKit?
NB viewDidAppear gets a call sooner than you think in terms of things. According to Apple's docs: "viewDidAppear notifies the view controller that its view has been added to the window." In other words, this can happen before any rotation is applied.
occulus Mar 04 '11 at 16:27 2011-03-04 16:27
source share