触摸时扩展 PickerViews 组件
我有一个 UIPickerView,其中要显示的组件数量可变。在它的控制器中,我有这个 -pickerView:withForComponent:
- (CGFloat)pickerView:(UIPickerView *)pv widthForComponent:(NSInteger)component {
CGFloat f;
if (component == 0) {
f = 30;
} else {
if ([componentsData count]>2) {
f = 260.0/([componentsData count]-1);
} else{
f = 260.0;
}
}
return f;
}
如果我调用 [pickerView reloadAllComponents]
,它可以正常工作,但是如果它被触摸(并且当然缩小所有其他的)?
I have a UIPickerView with a variable number of components to display. In its contoller i have this -pickerView:withForComponent:
- (CGFloat)pickerView:(UIPickerView *)pv widthForComponent:(NSInteger)component {
CGFloat f;
if (component == 0) {
f = 30;
} else {
if ([componentsData count]>2) {
f = 260.0/([componentsData count]-1);
} else{
f = 260.0;
}
}
return f;
}
this works fine if I call [pickerView reloadAllComponents]
, but how could I extend a components width if it is touched (and of course shrink all others)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为此,即使您的选择器选项都是文本,您也必须使用
您基本上需要为选择器选项生成 UIView 数组,并将它们保留在数组中。然后,当选择一行时,直接展开该 UIView,并迭代数组,相应地收缩其他数组。
To do this, even if your picker options are all text, you'll have to use
You'll basically need to generate an array of UIViews for your picker options, and retain them in an array. Then, when a row is selected, expand that UIView directly, and iterate through the array, contracting the others accordingly.