【发布时间】:2014-04-15 12:59:53
【问题描述】:
我有一个 UIScrollView,它的 frame 和 contentSize 大小相同。我想在键盘出现时更改scrollView的框架高度,但它不起作用。 如果我更改 x 或 y 位置,一切正常,但如果我尝试更改框架的宽度或高度,一切都保持不变,没有任何反应。
这是我的代码:
-(void)resizeContentView:(BOOL)resize forOffset:(CGFloat)offset
{
[UIView animateWithDuration:0.3f animations:^{
UIView* resizeView = [self getResizingView];
if ( !resizeView )
return;
CGRect rect = resizeView.frame;
if (resize)
{
rect.size.height -= offset;
}
else
{
rect.size.height += offset;
}
resizeView.frame = rect;
}];
}
我没有使用Autolayout,无论我是否使用动画,都会出现同样的问题。
【问题讨论】:
-
您是否尝试将 contentSize 与框架一起更改?
-
@dariaa 但我希望内容大小保持不变,因此孔屏可以滚动:/
标签: ios iphone uiscrollview resize frame