- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
UIGesturesRecognizer
有效地取代了
- touchesBegan:withEvent:
– touchesMoved:withEvent:
– touchesEnded:withEvent:
– touchesCancelled:withEvent:
只是在这里寻找确认。
谢谢
最佳答案
如果您说这些方法不会被调用,那是不正确的。
如果您说 UIGesture
可以执行此方法执行的操作,那么答案是肯定的,使用 UIGestures 您可以执行您发布的此方法可以执行的所有操作。并且可能以一种简单的方式编写代码:)
可以获取手势状态、 View 等。使用 UIGestures 很容易知道是点击、长按、滑动等。
看看 Reference
编辑:
一个给你的例子,添加一个 PanGesture,将在之后处理:
UIPanGestureRecognizer* pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panGestureHandler:)];
[self.view addGestureRecognizer:pan];
你的方法将处理平移,将接收手势,并且看起来像:
-(void)panGestureHandler:(UIPanGestureRecognizer *)gesture{
CGPoint postionInView = [gesture translationInView:self.view];
[yourView setCenter:postionInView];
}
关于ios - UIGestures 与手动控制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9899608/
我尝试使用以下代码将 UI 手势识别器添加到 Swift 中的 SKScene let recognizer = UISwipeGestureRecognizer(target: self, acti
UIGesturesRecognizer 有效地取代了 提供给我们的任何手动控制是否正确? - touchesBegan:withEvent: – touchesMoved:withEvent: –
想象一个透明的框架,比如图像框架,作为一个 UIImageview 和一个位于中间的 TextView 。 用户看到框架和中间的文本,但如果他尝试触摸文本,他认为他触摸了文本,但如果 z 位置在顶部.
我的表格 View 单元的 UI 遇到奇怪的交互缺陷。我实现了长按手势: func handleLongPress(sender:UILongPressGestureRecognizer!) {
我想知道是否有一个用于滚动的 UIGesture 识别器,就像在 tableView 上一样?那么,就像用户开始在 tableView 上滚动一样,UIGesture 识别器就会被触发吗?我尝试了 U
我在 IB 中创建了一些按钮并成功地将它们链接到操作。但是如果按钮被捏住,我想有另一个 Action 发生。我可能错过了一些基本的东西,但我似乎无法弄清楚如何将 UIPinchGestureRecog
我正在使用以下代码将两个手势识别器添加到 View 中。我想要的是:如果用户点击一件事。如果他们点击两次,就会发生另一件事。 实际上,无论用户点击一次还是两次,都会发生单击操作。换句话说,当我双击时,
我正在尝试通过长按手势来删除图像...问题是我可以在同一 View 上有多个图像。并且可能想要通过按住图像来删除每个图像。 所以可以说我有: @property (nonatomic, retain
我有这张图片: 我想要做的是向这个图像添加一个 UITapGestureRecognizer(或者我可以将图像拆分为它所包含的不同部分,并为每个部分添加一个 UITapGestureRecognize
当用户将手指平移到特定单元格上时,单元格会根据用户的 x 轴改变颜色。我将如何从平移手势更改为滑动手势。我想构建它,而不是平移,在单元格上滑动会显示它背后的颜色。然后,当用户抬起手指时,电池应弹回原位
我不明白我做错了什么 为什么 velocityInView:self.view & locationInView 发送到 UILongPressGestureRecognizer 而不是 UIPanG
关闭。这个问题需要details or clarity .它目前不接受答案。 想改进这个问题吗? 通过 editing this post 添加细节并澄清问题. 关闭 4 年前。 Improve t
我有一个 UITextField,它是 UIScrollView 的 subview 作为 UITextField 的一部分,我有一个单击手势(或者可能是旧触摸),使其成为第一响应者。我想向 UITe
我正在开发一个 iphone(iOS 4.0 或更高版本)应用程序,在处理多个 View 之间的触摸时遇到了一些问题。我有这样的 View 结构 ---> A superView |
我已将自定义 View 添加到我的 Root View 中,并添加了 UITapGesture。当调用 UITapGesture 代码的“sender.view”时,它不再由我的自定义 UIView
我正在尝试在应用程序中创建一个带有按钮的 View ,如果点击该按钮 3 次,就会发生某些事情。我查看了多个问题并使用了多个代码,但我就是无法让它工作。这是我的代码: #import "ViewCon
在 iOS 6 beta 4 和 iOS 5.1.1 中,我有左/右滑动功能,允许用户在托管在 UIViewController 中的不同 QLPreviewController 之间滑动。 在 iO
我想在我的应用中制作广告横幅。有点像iAd的。 我打算通过在 View 上有一个 UIImage 然后分配横幅图像来实现它。然后我会添加一个触摸手势,以便用户可以单击它并转到我的应用程序中的另一个 V
所以我正在做这个项目here ,来测试一些我感兴趣的东西,比如使用 UIGestures 的 View 转换。 我目前正在测试 View 转换在其中包含 UIWebViews 和 UIScrollVi
NSTimer 暂停一段时间,然后在执行 UIGesture 操作时再次启动。 我正在开发一个 iOS 应用程序,我必须每 0.5 秒重复触发一次 NSTimer,并根据该计时器移动歌曲进度条。当用户
我是一名优秀的程序员,十分优秀!