将videoGravity设置为AVLayerVideoGravityResizeAspectFill对iOS 5.0没有影响

Sou*_*Das 8 ios avplayer ios5

我已经实现了一个自定义电影播放器AVPlayer.在将videoGravity的值设置AVPlayerLayerAVLayerVideoGravityResizeAspectFillI 时,我会看到所需的效果iOS 4.2, 4.3.但不知何故,iOS 5.0它没有任何效果.有人看到类似的问题吗?难道我做错了什么?

mih*_*ham 17

在iOS5上,您应该在设置videoGravity后重置图层边界.

这对我有用:

((AVPlayerLayer *)[self layer]).videoGravity = AVLayerVideoGravityResizeAspectFill;
((AVPlayerLayer *)[self layer]).bounds = ((AVPlayerLayer *)[self layer]).bounds;
Run Code Online (Sandbox Code Playgroud)

EDITED: "self"指向一个PlayerView(UIView的子类)对象,例如"全部放在一起":https: //developer.apple.com/library/ios/#documentation/AudioVideo/Conceptual/AVFoundationPG/Articles/02_Playback. HTML