Iphone UIScrollView无法正确调整大小

Iphone UIScrollView无法正确调整大小,iphone,objective-c,uiview,uiviewcontroller,ios4,Iphone,Objective C,Uiview,Uiviewcontroller,Ios4,我有旋转和调整滚动视图大小的代码,这样当iPhone横向移动时,方向是正确的 这是旋转前视图的外观: 滚动视图为黄色 这就是它之后的样子: 这是我在为scroll视图设置新框架后所做的日志语句,您可以看到它显然不是它所说的应该是什么 CGRect for object after setting to new: UIScrollView, {{0, 100}, {480, 150}} [UIView animateWithDuration:kAnimationDuration an

我有旋转和调整滚动视图大小的代码,这样当iPhone横向移动时,方向是正确的

这是旋转前视图的外观:

滚动视图为黄色

这就是它之后的样子:

这是我在为scroll视图设置新框架后所做的日志语句,您可以看到它显然不是它所说的应该是什么

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;
            }];
        }
    }];
我错过了什么


谢谢

您确定旋转时UIScrollView的父视图没有重新布局吗?也许您需要在InterfaceOrientation的didRotateFromInterfaceOrientation:(UIInterfaceOrientation)中执行最终的调整大小操作,这样框架的大小就不会超出您的控制范围