我想实现的是列匹配类型功能。我在右栏上有三个按钮,在左栏上有三个按钮,上面有一些信息。我想通过拖动手指从右侧的一个按钮绘制路径到左侧的任何按钮。
我会使用 UIBezierPath
路径来绘制路径,为此绝对需要起点和终点。
现在的问题是如何通过点击按钮来触发 touchesBegan
、touchesMoved
和 touchesEnded
方法,以便我可以开始和结束点。
我正在考虑的另一个选择是用一个不可见的 UIView 覆盖所有按钮,并以某种方式检查这个覆盖 View 的触摸点是否位于任何按钮框架中。
顺便说一句,我也可以用简单的 UIImageView 替换这些按钮。我添加按钮只是为了获得接触点。
任何帮助。
最佳答案
创建 UIButton 的子类并添加这个...
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[super touchesBegan:touches withEvent:event];
[self.nextResponder touchesBegan:touches withEvent:event];
}
这会让您在按钮内进行触摸。
关于ios - 触摸开始 : withEvent: is not called when tapped on a UIButton,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17966879/