2015-11-03 125 views
0

我試圖創建一個相對簡單的應用程序,只需按下按鈕時播放視頻。我從AVKit使用AVPlayer似乎一切正常,但我運行該程序時收到有關約束的警告。AVPlayerView約束錯誤

不知道確切地說我有一個約束導致我一個問題。

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

回答

0

我得到了同樣的錯誤,我複製和粘貼後,從幾個蘋果的示例代碼的各種片段到我的應用程序,尚未知道你不能指定相同的約束一個UI元素兩次。

你可能做了同樣的事情;因此,請在項目範圍內搜索「AutoResizing」。無論您將playerView設置爲根據其父視圖,視圖控制器還是媒體自動調整大小。

我看着你的應用程序的代碼,我沒有看到任何地方調用的特定方法。要麼我忽略了它,要麼你在發佈這個問題後解決了問題。