我有一个子类 UIView 的自定义 View 。它有一个 touchesEnded 事件,但是它没有显示在 Interface Builder 中(在事件下)。我想知道如何将该方法放入我的 View Controller 中,以便在 touchesEnded 触发时触发一个方法。但是,我正在考虑使用目标操作,
下面的代码不起作用,因为 forControlEvents:UIControlEventTouchesEnded 不存在。所以我不知道如何从 UIView 的子类中获取 touchesEnded 方法。
[customView addTarget:self action:@selector(actionWithUIControlEvent:) forControlEvents:UIControlEventTouchUpInside];
任何帮助将非常感激!
最佳答案
只需让您的 View Controller 处理事件消息。实现 touchesEnded:withEvent:
方法,然后调用第二个。
关于objective-c - TouchesEnded 事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6727043/