gpt4 book ai didi

ios - 如何正确禁用 UIPickerView 组件滚动?

转载 作者:行者123 更新时间:2023-11-29 01:27:19 62 4
gpt4 key购买 nike

Aster 发现自己处于想要禁用 UIPickerView 组件的情况,并且找不到任何使用默认功能的答案,而是尝试通过使用标签或多个 UIPickerView 来绕过它,我开始探索 UIPickerView 结构以找到通过使用操作系统已有的功能来解决问题的更直接的方法。

最佳答案

所以这些是我的答案,我通过反复试验发现的,以及我使用它的方式:

方法:

- (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];
}

我希望这些能帮助那些发现自己处于与我相同处境的人:)

关于ios - 如何正确禁用 UIPickerView 组件滚动?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33860778/

62 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com