- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我尝试使用长按手势和配置为连续更新的步进器来设置 View 。长按时,不会出现步进器的连续特征。目前,我已禁用长按。我想我不需要它。但为了将来引用,我将如何允许两者共存?
需要明确的是,这是我尝试此操作时屏幕的设置方式。
按预期点击主视图功能。点击步进器将按预期运行。长按主视图可按预期运行。长按步进器则不会。
我修改了长按调用的代码来检查 subview 的框架,如果触摸位置位于该矩形内则不执行操作,但这没有什么区别。我没有尝试让长按在这种情况下失败,但我想接下来我会尝试一下。编辑:好吧,也许不是。似乎没有一个 API 可以实现这一点。然而,有this kludge ,我不会尝试。
随附的是探查器的屏幕截图,其中包含反向调用树,以便您可以看到每个项目正在被调用。
darkStepped:
是步进器调用的 IBAction。如果步进器是由手势识别器触发的,我难道不希望在调用树中看到手势识别器吗?
最佳答案
If the stepper were triggered by a gesture recognizer, wouldn't I expect to see the gesture recognizer in the call tree?
堆栈跟踪显示步进器的 _updateCount
方法是通过计时器调度的。
这可能与步进器具有“自动增量”模式这一事实有关,只要您按住它,它就会以给定的(变化的)速率更新。因此,步进器不是简单地调用 _updateCount
,而是设置一个计时器来处理此行为。
无论出于何种原因使用计时器,计时器都会解释为什么您在堆栈跟踪中看不到手势识别器。
在您的情况下,发生的情况是步进器获取触摸、处理它们,并且不将它们转发给与其相连的任何手势识别器。
这可以解释如下,尽管这段代码没有明确提到与 UIStepper
控件相关的长按识别器:
根据 Apple Docs :
Interacting with Other User Interface Controls In iOS 6.0 and later, default control actions prevent overlapping gesture recognizer behavior. For example, the default action for a button is a single tap. If you have a single tap gesture recognizer attached to a button’s parent view, and the user taps the button, then the button’s action method receives the touch event instead of the gesture recognizer. This applies only to gesture recognition that overlaps the default action for a control, which includes:
A single finger single tap on a UIButton, UISwitch, UIStepper, UISegmentedControl, and UIPageControl.
...
If you have a custom subclass of one of these controls and you want to change the default action, attach a gesture recognizer directly to the control instead of to the parent view. Then, the gesture recognizer receives the touch event first. As always, be sure to read the iOS Human Interface Guidelines to ensure that your app offers an intuitive user experience, especially when overriding the default behavior of a standard control.
因此,您似乎可以将手势识别器直接附加到控件(可能您需要子类化 UIStepper
才能工作,我不太确定如何解释最后一段)。希望这不会禁用步进器的基本工作(但也许会)。
关于ios - 如何让 stepper 和 longpress 共存?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20847475/
这段代码一直有效,直到我将我的项目从 ios4 转换为 ios6 (+ARC) 并将我的 xib 文件换成 Storyboard。现在我所做的任何点击都算作长按。 手势设置 - (void)viewD
我在我的集合 View 中使用 UILongPressGestureRecognizer,我希望长按手势识别器只有在满足特定条件时才能工作。 NSString *check; if([check
我将更改fabric.js中长按的延迟(使用eventjs构建),但它没有改变。我做错了什么? canvas.on('touch:longpress', longPress, { de
我的表格 View 单元的 UI 遇到奇怪的交互缺陷。我实现了长按手势: func handleLongPress(sender:UILongPressGestureRecognizer!) {
我已经尝试了一段时间来完成这项工作。这种方法似乎在互联网上的几个地方都有效,但不适合我。请注意,当我在手机上尝试时,这在 Dreamweaver(和 chrome)中有效,但在 Eclipse Ind
在我的 GestureDetector 中调用 LongPress 后,如何监听移动事件? 当用户 LongClick 时,他开始选择模式,并且可以将一个正方形拖到屏幕中。但是我注意到在消费了 Lon
当 customView 执行 longPress 时,我想在 customView 上启用 UIPanGestureRecognizer。 (我希望当你longPresscustomView时,cu
我正在尝试使 imageView 在长按时增加尺寸,并在我取消按下后恢复正常。 public class MainActivity extends Activity { private class E
嘿伙计们,我试图让一个 View 出现在父 View 中的长按上,并使其可拖动和可收缩,但就像现在一样,我只能使它成为可拖动的,但收缩不起作用。这是我的代码 class MainVC: UIViewC
我有一个 ListFragment Activity 。 我想为 onItemClickedLongPress 创建一个方法,以便当用户执行此操作时。弹出一个菜单。我熟悉创建菜单。 因此,如果有人愿意
我有一个 UITableView,我正在向它的 UITableViewCell 添加一个 UILongPressGestureRecognizer,如下所示: // Setup Event-Handl
目前我正在开发一个电子邮件应用程序,并希望通过我的应用程序打开所有带有 mailto 方案的链接,而不是默认的 Apple 邮件应用程序。 例如,我有一个这样的链接 mailto_test 在 UIW
我正在开发一个简单的 android 应用程序,我的要求是, “在屏幕上发生一些移动事件(MotionEvent.ACTION_MOVE 为真)后,如果用户在某处停止移动几秒钟而没有将手指从屏幕上移开
这似乎是一个有点奇怪的问题。我在迭代 tableViewCell 中有一个 UIButton在 tableView那是放在常规的ViewController .出于某种原因,它在长按时看起来只是被点击
我需要在适用于 Android 和 iOS 的 Flutter 行元素上实现长按选择。有什么帮助吗? 到目前为止我的代码: class ListElement extends StatelessWid
https://drive.google.com/file/d/0B0alJDsAgypmSElpZUZ1U05zcGM/view?usp=sharing我想要这样的东西,我检查了弧形菜单,但是我们点
我希望用户能够长按 volumeUp 硬件按钮以跳过歌曲,并在短按时执行常规的 volumeUp 操作。 我能够区分两者(我发现 this solution,使用 onKeyDown、onKeyLon
我尝试使用长按手势和配置为连续更新的步进器来设置 View 。长按时,不会出现步进器的连续特征。目前,我已禁用长按。我想我不需要它。但为了将来引用,我将如何允许两者共存? 需要明确的是,这是我尝试此操
All Boxes 是 UITextField。我想在用户长按 UITextField 时更改背景颜色。 长按哪个TextField UITextField颜色变了,不是所有的UITextField
在没有释放屏幕(使用手势检测器)的情况下调用 Longpress 后应该如何调用滚动事件? 这是我的类(class): public class TestingGestureDetector exte
我是一名优秀的程序员,十分优秀!