I have a very simple UIScrollView example that simply doesn't do what it's suposed to. Not sure if it's a bug with the API or a bug in my code.
Basically, I've got a UIViewController with a UIScrollView as it's view. When I add it to the UIWindow and change the orientation of the iPad I log out the UIScrollViews size, which is incorrectly(?) reported.
Here's my UIViewController implementation:
@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%f h%f", rect.width, rect.height);
}
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
CGSize rect = scrollView.frame.size;
NSLog(@"will animate rotation w%f h%f", rect.width, rect.height);
}
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
CGSize rect = scrollView.frame.size;
NSLog(@"did rotate w%f h%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, the orientation changes does resize the UIScrollView, but only to allow the new statusbar. I would expect that the width and height drastically change, as the UIScrollView is how wider than it is high and vice versa.
Is there a way to get the UIScrollView to report it's real size?