【发布时间】:2010-01-30 02:20:47
【问题描述】:
我在 .xib 中的 UIView 中的 UIScrollView 中有一个 UIView,其中包含多个按钮。如果我将 UIView 从 viewWillAppear 内向下移动几个像素,则按钮都会停止响应点击。
这是我用来调整 UIScrollView 大小并向下移动按钮的代码:
// adjust the view height to accomodate the resized label
scrollView.contentSize = CGSizeMake( 320, 367 + expectedLabelSize.height - originalLabelSize.height );
// Adjust the location of buttons
CGRect buttonsBounds = buttons.bounds;
buttonsBounds.origin.y -= expectedLabelSize.height - originalLabelSize.height; //XX
buttons.bounds = buttonsBounds;
如果我注释掉标记为 XX 的行,按钮可以正常工作,但当然是在错误的位置。
如果我尝试不同数量的像素(将expectedLabelSize.height - originalLabelSize.height 替换为硬编码值),我会得到有趣的结果。 10 像素工作正常。 50 像素使我的顶部按钮工作正常,但我的底部按钮失败。 100 像素,两个按钮都失败。 (-50) 像素导致底部按钮工作正常,但顶部按钮失败。
知道可能导致问题的原因吗?我是否需要以某种方式通知按钮其父视图已移动?
【问题讨论】:
标签: iphone objective-c uiview