I have a very simple UIScrollView example that just doesn't do what it was supposed to do. Not sure if this is an API error or an error in my code.
Basically, I have a UIViewController with a UIScrollView as I view it. When I add it to UIWindow and change the orientation of the iPad, I exit the UIScrollView format, which is incorrect (?).
Here is my implementation of the UIViewController :
@implementation CustomViewController - (void)loadView { scrollView = [[[UIScrollView alloc] init] autorelease]; scrollView.delegate = self; scrollView.backgroundColor = [UIColor redColor]; self.view = scrollView; } - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { CGSize rect = scrollView.frame.size; NSLog(@"will rotate w%fh%f", rect.width, rect.height); } - (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { CGSize rect = scrollView.frame.size; NSLog(@"will animate rotation w%fh%f", rect.width, rect.height); } - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { CGSize rect = scrollView.frame.size; NSLog(@"did rotate w%fh%f", rect.width, rect.height); } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return YES; } @end
When I run the above code, I see the following entries in my console:
2010-07-11 11:03:05.214 Untitled2[6682:207] will rotate w768.000000 h1004.000000 2010-07-11 11:03:05.214 Untitled2[6682:207] will animate rotation w748.000000 h1024.000000 2010-07-11 11:03:05.619 Untitled2[6682:207] did rotate w748.000000 h1024.000000 2010-07-11 11:03:07.951 Untitled2[6682:207] will rotate w748.000000 h1024.000000 2010-07-11 11:03:07.958 Untitled2[6682:207] will animate rotation w768.000000 h1004.000000 2010-07-11 11:03:08.367 Untitled2[6682:207] did rotate w768.000000 h1004.000000
As you can see, orientation changes resize the UIScrollView , but only to allow a new status bar. I would expect the width and height to change dramatically since the UIScrollView is both wider than tall and vice versa.
Is there any way to get UIScrollView to report the real size about it?
ios ipad uiscrollview orientation
d2kagw
source share