IOS裁剪webview上的iframe

时间:2015-08-20 10:03:43

标签: ios youtube-api

我正在尝试使用YTPlayerView嵌入YouTube视频,因此设置其框架并加载内容但视频正在裁剪:

enter image description here

-(void)viewDidLoad{
    [super viewDidLoad];
    NSDictionary *playerVars = @{
                             @"controls" : @0,
                             @"playsinline" : @1,
                             @"autohide" : @1,
                             @"showinfo" : @0,
                             @"modestbranding" : @1
                             };
    [self.view addSubview:self.playerView];
    [self.view addSubview:self.slider];
    [self.view addSubview:self.playButton];
    self.view.backgroundColor = [UIColor blackColor];
    self.playerView.delegate = self;
    [self.playerView loadWithVideoId:self.videoId playerVars:playerVars];
}

-(YTPlayerView *)playerView{
    if (!_playerView) {
        _playerView = [[YTPlayerView alloc] initWithFrame:CGRectMake(10, 84,      self.view.frame.size.width - 10, 250)];
    }
    return _playerView;
}

任何正确填充视图的方式?

1 个答案:

答案 0 :(得分:1)

_playerView.contentMode = UIViewContentModeScaleAspectFit;

在创建YTPlayerView的对象之后放置它。可能是它的作品。