objective-c - TouchesEnded 事件

标签 objective-c ios

我有一个子类 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/

相关文章:

objective-c - 如何使 UIAlertView 不根据 buttonIndex 关闭

ios - 为什么将我的对象添加到NSMutableArray无法正常工作?

ios - HealthKit:HKObserverQuery不触发

iOS 12 : validate local certificate with URLSession

ios - Peer2Peer CouchbaseListener

iphone - 继续在后台播放 MPMoviePlayerController 中的电影

objective-c - 大纲 View :objectValueForTableColumn:byItem: not called

php - 根本没有收到来自 Facebook 的实时更新

iphone - 删除使用 Storyboard创建的导航栏中的半透明栏

ios - CALayer 委托(delegate)仅在使用 Swift 时偶尔调用