iOS9中的AVPlayerViewController.videoBounds是错误的?

时间:2015-09-24 14:20:48

标签: ios objective-c ios9 avplayerviewcontroller

我已经将AVPlayerViewController子类化,需要查看UIButton以显示视频。我使用videoBounds property来布局此按钮,使用ReactiveCocoa:

@weakify(self);
[RACObserve(self, videoBounds) subscribeNext:^(NSValue *rect) {
    @strongify(self);
    NSLog(@"self.view : %@", NSStringFromCGRect(self.view.frame));
    NSLog(@"videoBounds : %@", NSStringFromCGRect(rect));

    button.frame = self.videoBounds; // for example
}];

这在iOS8中有效,但是从iOS9开始,这个属性似乎不再返回视频的正确边界。

日志:

0 - start with portrait:
self.view :{{0, 0}, {375, 667}}
videoBounds :{{0, 180.09090909090909}, {375, 306.81818181818176}}

1 - after rotating to landscape:
self.view :{{0, 0}, {667, 375}}
videoBounds :{{-41.666666666666686, 146}, {458.33333333333343, 375}}

2 - rotate back to portrait:
self.view :{{0, 0}, {375, 667}}
videoBounds :{{146, 34.090909090909093}, {375, 306.81818181818176}}

当你改变方向时,正确的框架将永远丢失......:'(

任何人偶然发现了相同的错误,或者有人为此解决了这个问题(手动计算视频边界?:/)

1 个答案:

答案 0 :(得分:0)

我遇到了同样的问题并通过从视图中删除播放器视图然后重新添加它来修复它。

resize()