【问题标题】:Multiple UITextView inside UIScrollView in paging mode interaction problem分页模式下UIScrollView内部的多个UITextView交互问题
【发布时间】:2020-04-29 17:27:01
【问题描述】:

我在基于 textContainer 的分页模式下在 UIScrollView 中创建多个 UITextView。 View structure

一切都按预期工作,但我想让 textView 可选择。所以我当然会在添加 scrollview 时将其设为 [textView setSelectable:YES]; 。 ScrollView canCancelContentTouchesdelaysContentTouches 设置为 NO 并且底层 textView 接收触摸,正如我通过覆盖 (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event 所看到的那样。但是 textView 仍然无法选择,当我在 textViews 中记录变量时,它显示 isSelectableisEditable 设置为 NO,无论我在添加为 scrollView 的子视图时是否将它们设置为 YES。 textView 的边界也不大于包含 scrollView 。 如果我将 UIButton 添加为 textView 的子视图,它也会收到 touches 。 如果只添加一个 textView,则选择和编辑工作正常。 有谁知道可能出了什么问题以及为什么触摸正在传递但文本事件没有触发?还是预期的行为?

【问题讨论】:

    标签: ios uiscrollview uikit uitextview textkit


    【解决方案1】:

    似乎,当多个 UITextView 有一个 textStorage 时,即使每个都有自己的容器,它也会变成静态的,你对此无能为力。 参考 iOS 7 Programming Pushing the Limits 一书的类似问题和答案: https://stackoverflow.com/a/41842189/12701117

    出于索引原因,我将留下问题和答案。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-05-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-23
      • 2017-07-14
      • 1970-01-01
      相关资源
      最近更新 更多