我知道这可能是一个重复的问题,但已经存在的问题并没有解决方案,所以,我再次要求可能开始提出问题。
以下是我在iOS 11下工作的代码:
AVPlayer *player = [AVPlayer playerWithURL:videoURL];
// create a player view controller
avcontroller = [[AVPlayerViewController alloc]init];
avcontroller.player = player;
[player play];
NSNotificationCenter *noteCenter = [NSNotificationCenter defaultCenter];
[noteCenter addObserverForName:AVPlayerItemDidPlayToEndTimeNotification
object:nil
queue:nil
usingBlock:^(NSNotification *note) {
NSLog(@"Video end");
self.avcontroller.player = nil;
[self.avcontroller.view removeFromSuperview];
[self.view addSubview:delegate.tabViewControllerObj.tabBarController.view];
}];
_skip =[UIButton buttonWithType:UIButtonTypeCustom];
[_skip addTarget:self action:@selector(btnSkipTapped)
forControlEvents:UIControlEventTouchUpInside];
[_skip setTitle:@"Skip" forState:UIControlStateNormal];
_skip.layer.borderWidth = 2.0f;
_skip.layer.cornerRadius = 12;
_skip.clipsToBounds = YES;
_skip.layer.borderColor = [UIColor whiteColor].CGColor;
// show the view controller
[self addChildViewController:avcontroller];
[avcontroller.view addSubview:_skip];
[avcontroller.view bringSubviewToFront:_skip];
[self.view addSubview:avcontroller.view];
avcontroller.view.frame = self.view.frame;
}
-(void)viewDidLayoutSubviews{
[super viewDidLayoutSubviews];
_skip.frame = CGRectMake((self.view.frame.size.width-140),(self.view.frame.size.height-150),100.0,35.0);
}
这里是按钮点击功能:
- (IBAction)btnSkipTapped{
NSLog(@"Skip button clicked");
self.avcontroller.player = nil;
[self.avcontroller.view removeFromSuperview];
[self.view addSubview:delegate.tabViewControllerObj.tabBarController.view];
}
此代码将完美显示按钮,但点击按钮后,它不会调用btnSkipTapped函数。 任何帮助将不胜感激!
答案 0 :(得分:3)
@DeepShah您已在 $('label span').on('click', function() {
check = $(this).prev().find('input:checkbox');
//is checked true = uncheck, false = check
(check.prop('checked') ? check.attr('checked', false) : check.attr('checked', true));
});
中添加了跳过按钮,因此其显示正常但您无法点击它,因为avcontroller.view
涵盖了该跳过按钮。
见下图:
因此您必须在AVPlayerViewControllerContentView
中添加跳过按钮及其功能。
self.view