如何在 AVPlayerViewController 中添加完成按钮? [英] How to adding done button in AVPlayerViewController?

查看:76
本文介绍了如何在 AVPlayerViewController 中添加完成按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 AVPlayerViewController 并且无法显示 完成 按钮,也无法关闭播放器.也许你可以帮助我.这是我在objective-c中的代码

I'm using AVPlayerViewController and can't showing the Done button, and can't close the player also. maybe you can help me. This is my code in objective-c

UIView *view = self.view;

NSURL *fileURL = [NSURL URLWithString: _detailData[0]];

AVPlayerViewController *playerViewController = [[AVPlayerViewController alloc] init];

playerViewController.player = [AVPlayer playerWithURL:fileURL];

self.avPlayerViewcontroller = playerViewController;

[self resizePlayerToViewSize];
[self dismissViewControllerAnimated:YES completion:nil];
[view addSubview:playerViewController.view];

[playerViewController.player play];

view.autoresizesSubviews = TRUE;

需要帮助的人,非常感谢.

Need help guys, thank you very much.

推荐答案

UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button addTarget:self 
           action:@selector(aMethod:)
 forControlEvents:UIControlEventTouchUpInside];
[button setTitle:@"Done" forState:UIControlStateNormal];
button.frame = CGRectMake(80.0, 210.0, 160.0, 40.0); // set your own position
[view addSubview:button]; // or you can add [playerViewController.view addSubview:button];

-(void)aMethod:(UIButton *)button {

 // Remove playerViewController.view
}

这篇关于如何在 AVPlayerViewController 中添加完成按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆