UIScrollView无法正确调整大小

时间:2010-10-27 16:02:19

标签: iphone objective-c uiview uiviewcontroller ios4

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

这是旋转前视图的样子:
alt text

滚动视图为黄色。

这就是它之后的样子:alt text

这是我在为滚动视图设置新框架后放置的日志语句,你可以看到它显然不是它应该是它的内容!

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;
            }];
        }
    }];

我缺少什么?

由于

1 个答案:

答案 0 :(得分:0)

您是否确定旋转时UIScrollView的父视图没有重新布局?也许您需要在- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation中进行最终调整大小,以便不会调整框架的大小。

相关问题