简体   繁体   English

UIScrollView,UIMenuController和LongPress手势

[英]UIScrollView, UIMenuController, and LongPress Gesture

I have UIButtons added on the fly inside a UIScrollView and I also have a “LongPressGesture” attached to the button so when I tap the button for more than 1 second, a menu pops up (using UIMenuController). 我在UIScrollView内动态添加了UIButton,并且还在按钮上附加了“ LongPressGesture”,因此当我点击按钮1秒钟以上时,会弹出一个菜单(使用UIMenuController)。

The problem is if I keep dragging my UIScrollView the menu does not move with the button which looks weird. 问题是,如果我一直拖动UIScrollView,菜单不会随着看起来很奇怪的按钮而移动。 But I am really looking for is to STOP the UIScrollView from scrolling once the UIMenuController appears. 但是我真正在寻找的是一旦UIMenuController出现,停止UIScrollView的滚动。

A perfect example is iMessage: You can drag all the messages up and down, but once you long press a message and the menu pops up, you CANNOT scroll anymore... iMessage就是一个完美的例子:您可以上下拖动所有消息,但是长按一条消息并弹出菜单后,就无法再滚动...

Can you not simply call -setScrollEnabled: on the scroll view and pass NO when you pop up your UIMenuController? 您不能简单地在滚动视图上调用-setScrollEnabled:并在弹出UIMenuController时传递NO吗? You'd need to find a way to re-enable scrolling when the menu dismisses, but at least the scroll view would refuse to scroll until that happens... 您需要找到一种在菜单关闭时重新启用滚动的方法,但是至少滚动视图会拒绝滚动,直到发生这种情况为止...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM