ios8 – MPMoviePlayerController布局约束问题

前端之家收集整理的这篇文章主要介绍了ios8 – MPMoviePlayerController布局约束问题前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在将应用程序移植到iOS 8.我有一些代码可以播放之前正在运行的视频,但现在却没有.

当我运行它时,我收到以下错误

(
"<NSLayoutConstraint:0x7faba2df5940 H:|-(34)-[MPKnockoutButton:0x7faba2e6d750](LTR)   (Names: '|':_UIBackdropContentView:0x7faba2dc38c0 )>","<NSLayoutConstraint:0x7faba2d51780 H:[MPKnockoutButton:0x7faba2e6d750]-(34)-[MPDetailSlider:0x7faba2dc6440](LTR)>","<NSLayoutConstraint:0x7faba2d5b7f0 H:[MPDetailSlider:0x7faba2dc6440]-(34)-[UIView:0x7faba2dc4060](LTR)>","<NSLayoutConstraint:0x7faba2dc5da0 UIView:0x7faba2dc4060.right == _UIBackdropView:0x7faba2dbfdc0.right>","<NSLayoutConstraint:0x7faba2dc58d0 H:|-(0)-[_UIBackdropView:0x7faba2dbfdc0]   (Names: '|':MPVideoPlaybackOverlayView:0x7faba2dbf6a0 )>","<NSLayoutConstraint:0x7faba2dc5950 H:[_UIBackdropView:0x7faba2dbfdc0]-(0)-|   (Names: '|':MPVideoPlaybackOverlayView:0x7faba2dbf6a0 )>","<NSLayoutConstraint:0x7faba2df9b10 H:[MPVideoPlaybackOverlayView:0x7faba2dbf6a0(0)]>","<NSAutoresizingMaskLayoutConstraint:0x7faba2dfbfa0 h=-&- v=-&- _UIBackdropContentView:0x7faba2dc38c0.midX == _UIBackdropView:0x7faba2dbfdc0.midX>","<NSAutoresizingMaskLayoutConstraint:0x7faba2dfbff0 h=-&- v=-&- _UIBackdropContentView:0x7faba2dc38c0.width == _UIBackdropView:0x7faba2dbfdc0.width>"
)

这是代码

movieController = [[MPMoviePlayerController alloc]
                 initWithContentURL:[NSURL URLWithString:playlistUrl]];

movieController.movieSourceType = MPMovieSourceTypeStreaming;
[movieController.view setFrame:[self.playerView bounds]];

[self.playerView addSubview:movieController.view];
[movieController play];

有什么想法吗?

解决方法

这似乎在iOS 8.1中得到修复.升级错误消失了.

但是,我确实需要稍微修改我的代码

movieController = [[MPMoviePlayerController alloc]
                    initWithContentURL:[NSURL URLWithString:playlistUrl]];

movieController.movieSourceType = MPMovieSourceTypeStreaming;

[movieController.view setTranslatesAutoresizingMaskIntoConstraints:NO];
[playerView addSubview:movieController.view];

id views = @{ @"player": movieController.view };

[playerView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[player]|"
                                                                       options:0
                                                                       metrics:nil
                                                                         views:views]];

[playerView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[player]|"
                                                                       options:0
                                                                       metrics:nil
                                                                         views:views]];
[movieController play];
原文链接:https://www.f2er.com/iOS/334299.html

猜你在找的iOS相关文章