UIScrollView does not resize correctly
I have code to rotate and size a scrollview, such that when the iPhone is landscape the orientation is correct.
This is what the view looks like before rotating:
The scroll view is in yellow.
This is what it looks like after:
This is the log statement i put after setting the new frame for the scroll view, and you can see that it is clearly not what it says its supposed to be!
CGRect for object after setting to new: UIScrollView, {{0, 100}, {480, 150}}
[UIView animateWithDuration:kAnimationDuration animations:^{
CGRect boundsRect = anObject.frame;
boundsRect.origin.x = x;
boundsRect.origin.y = y;
boundsRect.size.width = width;
boundsRect.size.height = height;
anObject.frame = boundsRect;
NSLog(@"CGRect for object after setting to new: %@, %@",[anObject class], NSStringFromCGRect(anObject.frame));
} completion:^ (BOOL finished){
if (finished) {
[UIView animateWithDuration:kAnimationDuration animations:^{
anObject.alpha = 1.0;
}];
}
开发者_运维百科 }];
What am i missing?
Thanks
Are you sure that the parent view of the UIScrollView isn't re-laying it out when you rotate? Perhaps you need to do the final resize in - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
so the frame doesn't get resized out of your control.
精彩评论