有没有人知道如何在可滚动视图上修复AVPlayer位置我使用以下代码来设置AVPlayer帧但是当设备大小改变时,它在不同大小上保持相同的大小并且我还有一个可滚动的查看因为这个代码我使用视图滚动在后台,玩家仍然在一个地方修复。任何帮助表示赞赏。
//here is my code
- (void)viewDidLoad {
[super viewDidLoad];
NSString *localfilepath=[NSString stringWithFormat:@"%@",[managedObject valueForKey:@"clip_path"]];
player = [AVPlayer playerWithURL:url];
AVPlayerViewController *controller = [[AVPlayerViewController alloc] init];
[self addChildViewController:controller];
[self.view addSubview:controller.view];
controller.view.frame = CGRectMake(10,80,300,250);
controller.player = player;
controller.showsPlaybackControls = YES;
[player pause];
}
答案 0 :(得分:0)
1.您的视图控制器符合UIScrollViewDelegate协议
2.in - (void)viewDidLoad,将滚动视图的委托设置为self,如
self.scrollView.delegate = self;
3.implement - (void)scrollViewDidScroll:(UIScrollView *)scrollView,例如
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
CGPoint offset = scrollView.contentOffset;
UIView *avplayerView = [self getAVPlayerView];
avplayerView.frame = CGRectMake(10, 80 + offset.y, 300, 250);
}
希望这有用