i have subclassed an AVPlayerViewController and need to view a UIButton to show over the video. I use the videoBounds
property to layout this button, using 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
}];
This has worked in iOS8, but since iOS9 it seems that this property doesn't return the correct bounds of the video anymore.
logs:
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}}
When you change orientation, the correct frame will be lost forever... :'(
Anyone stumbled onto the same bug, or does someone have a solution for this (calculate the videoBounds manually? :/)