Skip to content

如何监听控制层上的按钮点击事件?

changsanjiang edited this page Nov 25, 2020 · 1 revision

这里以监听播放按钮的点击为例:

  1. 获取对应的item, 并注册通知:
- (void)test {   
    SJEdgeControlButtonItem *playItem = [_player.defaultEdgeControlLayer.bottomAdapter itemForTag:SJEdgeControlLayerBottomItem_Play];
    [NSNotificationCenter.defaultCenter addObserver:self selector:@selector(itemActionDidPerformWithNote:) name:SJEdgeControlButtonItemPerformedActionNotification object:playItem];
}
  1. 实现通知回调:
- (void)itemActionDidPerformWithNote:(NSNotification *)note {
#ifdef DEBUG
    NSLog(@"%d - %s", (int)__LINE__, __func__);
#endif
}