【发布时间】:2020-04-29 17:27:01
【问题描述】:
我在基于 textContainer 的分页模式下在 UIScrollView 中创建多个 UITextView。 View structure
一切都按预期工作,但我想让 textView 可选择。所以我当然会在添加 scrollview 时将其设为 [textView setSelectable:YES]; 。 ScrollView canCancelContentTouches 和 delaysContentTouches 设置为 NO 并且底层 textView 接收触摸,正如我通过覆盖 (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event 所看到的那样。但是 textView 仍然无法选择,当我在 textViews 中记录变量时,它显示 isSelectable 和 isEditable 设置为 NO,无论我在添加为 scrollView 的子视图时是否将它们设置为 YES。
textView 的边界也不大于包含 scrollView 。
如果我将 UIButton 添加为 textView 的子视图,它也会收到 touches 。
如果只添加一个 textView,则选择和编辑工作正常。
有谁知道可能出了什么问题以及为什么触摸正在传递但文本事件没有触发?还是预期的行为?
【问题讨论】:
标签: ios uiscrollview uikit uitextview textkit