【发布时间】:2018-10-16 10:49:04
【问题描述】:
我的功能是在点击 textField 时打开选择器。我的文本字段在滚动视图内,如下图所示。
我想在选择器打开时禁用滚动视图的用户交互。以下是我的代码。
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
[self.picker removeFromSuperview];
[self.toolBar removeFromSuperview];
textField.inputView = self.picker;
textField.inputAccessoryView = self.toolBar;
self.scrollview.userInterationEnabled = NO;
return YES;
}
当我评论 userInteractionEnabled 代码时。 Picker 正在完美打开。但是当我取消注释代码选择器没有打开。
我还为这段代码提供了一些延迟。所以在 dalay 之后,我的选择器又被隐藏了。
【问题讨论】:
-
可能是因为 yopur textFieled 是滚动视图的子视图,可能尝试在滚动视图上使用 isScrollEnabled。您也可以尝试在作为 textField 的 inputView 插入的根视图中显示选择器。关于 userInteractionEnabled stackoverflow.com/questions/10880868/… 的信息
-
问题解决了吗?
标签: ios objective-c xcode