AVPlayerView的约束错误

时间:2015-11-03 13:57:17

标签: xcode swift

我正在尝试创建一个相对简单的应用程序,只需在按下按钮时播放视频。我正在使用AVKit的AVPlayer一切似乎工作正常,但我在运行程序时会收到有关约束的警告。

不知道我究竟有哪个约束导致我出现问题。

Unable to simultaneously satisfy constraints.
    Probably at least one of the constraints in the following list is one you don't want. 
Try this: 
    (1) look at each constraint and try to figure out which you don't expect; 
    (2) find the code that added the unwanted constraint or constraints and fix it. 
(Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) 
(
"<NSAutoresizingMaskLayoutConstraint:0x7ffc5acdc030 h=-&- v=-&- _UIBackdropContentView:0x7ffc5adc6d10.width == _UIBackdropView:0x7ffc5adbfd80.width>",
"<NSLayoutConstraint:0x7ffc5ad94a40 H:|-(0)-[UIView:0x7ffc5ad94e50]   (Names: '|':UIView:0x7ffc5ad35c90 )>",
"<NSLayoutConstraint:0x7ffc5ad94a90 H:[UIView:0x7ffc5ad94e50]-(0)-|   (Names: '|':UIView:0x7ffc5ad35c90 )>",
"<NSLayoutConstraint:0x7ffc5ad96720 H:|-(0)-[UIView:0x7ffc5ad35c90]   (Names: '|':AVPlayerView:0x7ffc5ad356e0 )>",
"<NSLayoutConstraint:0x7ffc5ad96770 H:[UIView:0x7ffc5ad35c90]-(0)-|   (Names: '|':AVPlayerView:0x7ffc5ad356e0 )>",
"<NSLayoutConstraint:0x7ffc5d068110 H:|-(0)-[UIView:0x7ffc5adc6890]   (Names: '|':_UIBackdropContentView:0x7ffc5adc6d10 )>",
"<NSLayoutConstraint:0x7ffc5d068190 H:[UIView:0x7ffc5adc6890]-(0)-|   (Names: '|':_UIBackdropContentView:0x7ffc5adc6d10 )>",
"<NSLayoutConstraint:0x7ffc5d067e80 H:|-(0)-[_UIBackdropView:0x7ffc5adbfd80]   (Names: '|':UIView:0x7ffc5adbeb70 )>",
"<NSLayoutConstraint:0x7ffc5d067f00 H:[_UIBackdropView:0x7ffc5adbfd80]-(0)-|   (Names: '|':UIView:0x7ffc5adbeb70 )>",
"<NSLayoutConstraint:0x7ffc5d067b30 H:|-(0)-[UIView:0x7ffc5adbeb70]   (Names: '|':AVAlphaUpdatingView:0x7ffc5adbd530 )>",
"<NSLayoutConstraint:0x7ffc5d067b80 H:[UIView:0x7ffc5adbeb70]-(0)-|   (Names: '|':AVAlphaUpdatingView:0x7ffc5adbd530 )>",
"<NSLayoutConstraint:0x7ffc5acd5b20 H:|-(34)-[AVButton:0x7ffc5adc76f0](LTR)   (Names: '|':UIView:0x7ffc5adc6890 )>",
"<NSLayoutConstraint:0x7ffc5acdccc0 H:[AVButton:0x7ffc5adc76f0]-(15)-[UILabel:0x7ffc5ac741a0'0:00'](LTR)>",
"<NSLayoutConstraint:0x7ffc5acdca20 H:[UILabel:0x7ffc5ac741a0'0:00']-(12)-[AVScrubber:0x7ffc5acb8ec0](LTR)>",
"<NSLayoutConstraint:0x7ffc5acdca70 AVScrubber:0x7ffc5acb8ec0.right == UILabel:0x7ffc5adf2ed0'--:--'.left - 12>",
"<NSLayoutConstraint:0x7ffc5acdcf00 UILabel:0x7ffc5adf2ed0'--:--'.right == AVButton:0x7ffc5adf3a70.left - 15>",
"<NSLayoutConstraint:0x7ffc5acdcfa0 AVButton:0x7ffc5adf3a70.right == AVButton:0x7ffc5d0051d0.left - 10>",
"<NSLayoutConstraint:0x7ffc5acdceb0 AVButton:0x7ffc5d0051d0.right == AVButton:0x7ffc5d00b190.left - 10>",
"<NSLayoutConstraint:0x7ffc5acdd240 AVButton:0x7ffc5d00b190.right == UIView:0x7ffc5adc6890.right - 34>",
"<NSLayoutConstraint:0x7ffc5adb15f0 H:|-(0)-[AVAlphaUpdatingView:0x7ffc5adbd530]   (Names: '|':UIView:0x7ffc5ad94e50 )>",
"<NSLayoutConstraint:0x7ffc5adb8460 H:[AVAlphaUpdatingView:0x7ffc5adbd530]-(0)-|   (Names: '|':UIView:0x7ffc5ad94e50 )>",
"<NSLayoutConstraint:0x7ffc5acd4c80 'UIView-Encapsulated-Layout-Width' H:[AVPlayerView:0x7ffc5ad356e0(100)]>"
)

项目在这里https://github.com/jeffellin/VideoPlayer

1 个答案:

答案 0 :(得分:0)

我将Apple的几个示例代码中的各种代码片段复制并粘贴到我的应用程序后,得到了同样的错误,但还不知道您不能两次为单个UI元素指定相同的约束。

你可能做了同样的事情;因此,在项目范围内搜索“AutoResizing”。无论您将playerView设置为根据其父视图,视图控制器还是媒体自动调整其大小。

我看了你的应用程序的代码,我没有看到任何地方调用的特定方法。要么我忽略了它,要么你自发布这个问题后解决了问题。