iPad – UiScrollView does not have new size on the direction change

I have a very simple UIScrollView example that does not do what it is supposed to do at all.
Not sure if it is a bug in the API or a bug in my code.

Basically, I have a UIViewController with UIScrollView as its view.
When I add it to the UIWindow and change the orientation of the iPad, I log out the UIScrollViews size, which is the error (?) Reported.

This is 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%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;< br /> NSLog(@"did rotate w%fh%f", rect.width, rect.height);
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {< br /> return YES;
}

@end

When I run the above code, I see the following entry in the console:

< p>

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, Fang To change the size of the UIScrollView does adjust the size of the UIScrollView, but only allows a new status bar.
I hope the width and height will change drastically, because the width and width of the UIScrollView are higher than it, and vice versa.

< p>Is there a way to make UIScrollView report its actual size?

If you are still looking, I have the answer. Test the border, not the frame.

Reason: frame is a derived attribute of the border and the transformation applied to the rotation.

I have a very simple UIScrollView example, which does not do it at all What it should do.
Not sure if it is a bug of the API or a bug in my code.

Basically, I have a UIViewController with a UIScrollView as its view.
When I add it to the UIWindow and change the orientation of the iPad, I log out the UIScrollViews size, which is wrong (?) reported.

This is 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%fh%f", rect.width, rect.height);
}

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation durati on:(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 entry in the 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 change does adjust the UIScrollView Size, but only the new status bar is allowed.
I hope the width and height will change drastically, because the width and width of UIScrollView are higher than it, and vice versa.

Is there a way to make UIScrollView Report its actual size?

If you are still looking, I have the answer. Test the boundary, not the frame.

Reason: frame is the boundary The derived properties of and the transformation applied to the rotation.

Leave a Comment

Your email address will not be published.