【问题标题】:UIScrollView does not resize correctlyUIScrollView 无法正确调整大小
【发布时间】:2010-10-27 16:02:18
【问题描述】:

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

这是视图在旋转之前的样子:

滚动视图是黄色的。

这是之后的样子:

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

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

我错过了什么?

谢谢

【问题讨论】:

    标签: iphone objective-c uiview uiviewcontroller ios4


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2014-04-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-14
      • 2019-05-06
      • 2011-03-24
      • 1970-01-01
      相关资源
      最近更新 更多