将 UIGesture 添加到按钮
我在 IB 中创建了许多按钮并将它们成功链接到操作。但如果按下按钮,我希望发生另一个操作。我可能错过了一些基本的东西,但我似乎无法弄清楚如何将 UIPinchGestureRecognizer 添加到按钮。
I created a number of buttons in IB and linked them to actions successfully. But I would like to have another action occur if the button is pinched. There is probably something basic that I have missed but I don't seem to be able to figure out how to add the UIPinchGestureRecognizer to the button.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不可以将 UIPinchGestureRecognizer 添加到按钮,通常我们会将其添加到右侧的视图中。我认为对于 UIButton 来说,可用的操作就像 IB 中定义的“TouchUpInside”一样。
i dont u can add a UIPinchGestureRecognizer to the button normally we will add it into the View right. i think for UIButton the actions available just like "TouchUpInside" as defined in the IB.
据我所知,您可以向
UIButton
添加手势。这是一小段代码,可以让您有一个总体思路:
我认为您不必执行整个
initWithTarget:self action:...
但这是我成功完成的唯一方法由某种类型的UIGestures
引起的视觉变化。如果您按照我的示例:
@selector(someAction:)];
您将声明如下方法:As far as I know, you can add a gesture to a
UIButton
.Here is a small piece of code to give you a general idea:
I don't think you have to do the whole
initWithTarget:self action:...
but this is the only way I have successfully done visual changes that are caused byUIGestures
of some type.If your following my example:
@selector(someAction:)];
you will declare the method like this: