【发布时间】:2011-06-08 05:31:03
【问题描述】:
我有一个带有文本字段和标签的滚动视图作为其子视图,对于两个文本字段我想显示 UIpickerview。 例如:当用户触摸 textfield11 时,我想显示一个从屏幕底部向上滑动的选择器,此时我也想更改滚动视图的高度,但它不起作用。
CGRect scrollframe = scrollView.frame;
NSLog(@"scrollframe.height=%f, pick height=%f",scrollframe.size.height, pick.frame.size.height);
scrollframe.size.height -= pick.frame.size.height;
[UIView beginAnimations:@"start" context:NULL];
[UIView setAnimationDuration:0.2];
[UIView setAnimationBeginsFromCurrentState:YES];
[scrollView setFrame:scrollframe];
NSLog(@"scroll height = %f",scrollframe.size.height);
NSLog(@"scrollview height = %f", scrollView.frame.size.height);
[pick setFrame:CGRectOffset([pick frame], 0, -220)];
[UIView commitAnimations];
这是控制台日志..
2011-06-08 10:43:31.316 AESDirect[281:207] scrollframe.height=416.000000,选择高度=216.000000 2011-06-08 10:43:31.316 AESDirect [281:207] 滚动高度 = 200.000000 2011-06-08 10:43:31.317 AESDirect [281:207] 滚动视图高度 = 200.000000
【问题讨论】:
-
为什么要增加滚动视图的高度?如果您想要向上移动其他字段,您可以更改滚动视图的 contentoffset
-
我不是想增加它的高度,我想降低它的高度,就像我们想要防止键盘隐藏文本字段时所做的那样
-
只有你可以改变 contentOffset 而不是高度。设置滚动视图的内容偏移量,字段将相应上升
-
@problemChild 嗨,选择器是否在制作动画时向上移动?
-
@sripriya 是的,选择器在制作动画时正在移动。
标签: iphone objective-c ios ios4 uiscrollview