iOS 9 AVPlayer旋转麻烦

时间:2015-11-04 09:06:57

标签: ios objective-c avplayer

我有一些奇怪的事情 - 在AVPlayer旋转之后,我通过计时器更新textField和进度滑块,但是使用控制器查看在AVPlayer之后更改坐标

mPlayer = [[AVPlayer alloc] init];
mPlayer = [mPlayer initWithURL:streamURL];
playerLayer = [AVPlayerLayer playerLayerWithPlayer:mPlayer];
[[[self view] layer] insertSublayer:playerLayer atIndex:0];
[playerLayer setFrame:self.view.bounds];

旋转

-(void) didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{

    playerLayer.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height - self.ButtonsView.frame.size.height);
    if([[UIDevice currentDevice]orientation]==UIDeviceOrientationLandscapeLeft||[[UIDevice currentDevice]orientation]==UIDeviceOrientationLandscapeRight)
    {

        self.ButtonsView.frame = CGRectMake((self.view.frame.size.width - self.ButtonsView.frame.size.width) /2, playerLayer.frame.size.height, self.view.frame.size.width, self.ButtonsView.frame.size.height);
    }
}

并且在更改计时器后,ButtonView的坐标变错了

- (void)updateTime:(NSTimer *)timer {
    self.tfCurrent.text = [self textFormatting : self.videoCurrentTime];
}
第一个第二个coords是好的。为什么我的视图会重绘?谢谢!

0 个答案:

没有答案