【问题标题】:onLongPressGesture makes list item not scrollable in SwiftUIonLongPressGesture 使列表项在 SwiftUI 中不可滚动
【发布时间】:2019-11-28 13:53:59
【问题描述】:

我有一个List 并且想让列表项响应长按手势。但是在将手势添加到列表项后,我无法从文本区域滚动列表。

List {
  ForEach(items) { item in
    Text(item.name)
      .onLongPressGesture { print("long press") }
  }
}

【问题讨论】:

标签: swiftui-list swiftui


【解决方案1】:

也许你应该发布更多代码......

我刚刚用 13.2 对其进行了测试...使用此代码 -> 有效

struct ContentView: View {
    var body: some View {
        List {
            ForEach(UIFont.familyNames, id: \.self) { item in
            Text(item)
              .onLongPressGesture { print("long press") }
          }
        }
    }
}

【讨论】:

  • 嗨,克里斯,试着将手指放在文本上并滚动。
  • 当您在长按后不抬起手指的情况下向下滑动时,您是否期望长按后滚动!?
  • 哦,我的意思是当你从文本开始滚动时,它不起作用。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-12-07
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多