Closed haolizi closed 6 years ago
step1:AppDelegate监听触摸事件,判断触摸范围是否在状态栏,是的话则发起触摸状态栏通知;
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
[super touchesBegan:touches withEvent:event];
CGPoint touchLocation = [[[event allTouches] anyObject] locationInView:self.window];
CGRect statusBarFrame = [UIApplication sharedApplication].statusBarFrame;
if (CGRectContainsPoint(statusBarFrame, touchLocation)) {
[[NSNotificationCenter defaultCenter] postNotificationName:StatusBarTouchBeginNotification object:nil];
}
}
step2:在播放视频列表页面注册触摸状态栏通知;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(statusBarTouchBegin) name:StatusBarTouchBeginNotification object:nil];
step3:修改当前播放索引currentIndex为0,表示当前播放第一个视频。
- (void)statusBarTouchBegin {
_currentIndex = 0;
}
注:currentIndex属性添加了KVO,currentIndex改变即可改变当前正在播放的视频。修改代码已经提交,看看还有什么问题吧。
嗯 晓得了,多谢
你好,点击状态栏滚动到顶部,视频就不能播放了,请问该该怎么解决?