0

私は AVPlayerViewController をサブクラス化し、ビデオの上に表示するために UIButton を表示する必要があります。ReactiveCocoaを使用して、videoBounds プロパティを使用してこのボタンをレイアウトします。

@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}}

向きを変えると、正しいフレームが永久に失われます... :'(

誰かが同じバグに遭遇したか、誰かがこれに対する解決策を持っていますか (videoBounds を手動で計算しますか? :/)

4

1 に答える 1

0

同じ問題に遭遇し、ビューからプレーヤー ビューを削除してから再度追加することで修正しました。

override func viewDidLayoutSubviews() {
    super.viewDidLayoutSubviews()
    timerLabelContainer.setNeedsDisplay()
    player.view.removeFromSuperview()
    playerContainer.addSubview(player.view)
}
于 2016-04-02T14:16:11.443 に答える