在 iOS 中 - 在滚动视图中触摸文本字段时,视图无法滚动

Pet*_*Bob 4 iphone xcode interface scrollview textfield

当尝试通过触摸和拖动文本字段来滚动视图时,类似于您在 iPhone 上的编辑联系人视图上滚动的方式,视图不会移动,在文本字段之间触摸和拖动或移到一边滚动视图中的文本字段有效,但在触摸文本字段时无效。

任何见解将不胜感激。谢谢!

Jam*_*mes 5

尝试将您添加到文本字段的delaysContentTouches属性设置YESUIScrollView。如果您触摸然后在文本字段中拖动,这应该允许您滚动。


sho*_*hoe 5

设置delaysContentTouchestrue对我也不起作用。所做的是遍历滚动视图的手势识别器并分别设置它们的delaysTouchesBeganand 和cancelsTouchesInViewtotruefalse

scrollView.gestureRecognizers?.forEach {

    $0.delaysTouchesBegan = true; $0.cancelsTouchesInView = false
}
Run Code Online (Sandbox Code Playgroud)