【发布时间】:2015-11-22 22:01:54
【问题描述】:
Aster 发现自己处于想要禁用 UIPickerView 组件并且没有找到任何使用默认功能但试图通过使用标签或多个 UIPickerViews 解决它的情况下,我开始在 UIPickerView 结构中寻找通过使用操作系统已经存在的功能来解决问题的更直接的方法。
【问题讨论】:
标签: ios iphone uigesturerecognizer uipickerview uipickerviewcontroller
Aster 发现自己处于想要禁用 UIPickerView 组件并且没有找到任何使用默认功能但试图通过使用标签或多个 UIPickerViews 解决它的情况下,我开始在 UIPickerView 结构中寻找通过使用操作系统已经存在的功能来解决问题的更直接的方法。
【问题讨论】:
标签: ios iphone uigesturerecognizer uipickerview uipickerviewcontroller
这就是我的答案,我通过反复试验找到的,以及我使用它的方式:
方法:
- (void)dissableUIPickerViewComponent:(int)componentToDissable forPickerView:(UIPickerView *)pickerView{
NSArray *pickerViews = [[NSArray alloc] initWithArray:[pickerView subviews]];
UIView *mainSubview;
for (int count = 0; count < pickerViews.count; count++) {
UIView *temp = [pickerViews objectAtIndex:count];
if (temp.frame.size.height > 100) {
mainSubview = temp;
}
}
NSArray *componentSubview = [mainSubview subviews];
while ([[[[componentSubview objectAtIndex:componentToDissable] subviews] firstObject] superview].gestureRecognizers.count) {
[[[[[componentSubview objectAtIndex:componentToDissable]subviews]firstObject]superview] removeGestureRecognizer:[[[[[componentSubview objectAtIndex:componentToDissable]subviews]firstObject]superview].gestureRecognizers objectAtIndex:0]];
}
}
最佳通话地点:
- (void)viewDidAppear:(BOOL)animated{
[self dissableUIPickerViewComponent:0 myPickerView];
}
我希望这些可以帮助那些发现自己处于与我相同的位置的其他人:)
【讨论】: