无法同时满足约束警告与故事板中嵌入的AVPlayerViewController

时间:2015-09-30 07:32:22

标签: ios objective-c xcode autolayout avplayerviewcontroller

我试图通过嵌入单独的视图控制器来完全通过故事板设置AVPlayerViewController。

步骤:

  1. 在Xcode中创建单一视图应用程序。
  2. 将VC嵌入导航控制器。
  3. 在底部添加工具栏。(固定到superView(前导,尾随,底部布局指南,高度(44))。
  4. 在父视图控制器中添加容器视图。(固定到superView(前导,尾随),顶部布局指南,工具栏顶部)。
  5. 删除容器视图附带的默认View Controller。
  6. 从对象库中拖动AV Player View Controller对象。
  7. 将容器视图中的嵌入segue连接到AV Player View Controller。
  8. 无代码添加。

    这就是我的故事板

    enter image description here

    查看层次结构:

    enter image description here

    一切运行良好: 但问题是: 我一运行它就会在调试器中收到这些警告:

    2015-09-30 12:58:35.904 AVPlayerTest[9352:446772] 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:0x7f93259513b0 h=-&- v=-&- _UIBackdropContentView:0x7f9325860000.width == _UIBackdropView:0x7f932585e990.width>",
        "<NSLayoutConstraint:0x7f932592bc70 H:|-(14)-[UILabel:0x7f9325925590'Hi-Speed Scrubbing']   (Names: '|':_UIBackdropContentView:0x7f9325860000 )>",
        "<NSLayoutConstraint:0x7f932592bcf0 H:[UILabel:0x7f9325925590'Hi-Speed Scrubbing']-(14)-|   (Names: '|':_UIBackdropContentView:0x7f9325860000 )>",
        "<NSLayoutConstraint:0x7f932592b770 H:|-(0)-[_UIBackdropView:0x7f932585e990]   (Names: '|':UIView:0x7f932585e830 )>",
        "<NSLayoutConstraint:0x7f932592b7f0 H:[_UIBackdropView:0x7f932585e990]-(0)-|   (Names: '|':UIView:0x7f932585e830 )>",
        "<NSLayoutConstraint:0x7f932592b450 H:|-(0)-[UIView:0x7f932585e830]   (Names: '|':AVAlphaUpdatingView:0x7f932585e310 )>",
        "<NSLayoutConstraint:0x7f932592b4d0 H:[UIView:0x7f932585e830]-(0)-|   (Names: '|':AVAlphaUpdatingView:0x7f932585e310 )>",
        "<NSLayoutConstraint:0x7f932594aa10 'UIView-Encapsulated-Layout-Width' H:[AVAlphaUpdatingView:0x7f932585e310(0)]>"
    )
    
    Will attempt to recover by breaking constraint 
    <NSLayoutConstraint:0x7f932592bcf0 H:[UILabel:0x7f9325925590'Hi-Speed Scrubbing']-(14)-|   (Names: '|':_UIBackdropContentView:0x7f9325860000 )>
    
    Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
    The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
    2015-09-30 12:58:35.905 AVPlayerTest[9352:446772] 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:0x7f93259513b0 h=-&- v=-&- _UIBackdropContentView:0x7f9325860000.width == _UIBackdropView:0x7f932585e990.width>",
        "<NSLayoutConstraint:0x7f932592bdd0 H:|-(14)-[UILabel:0x7f9325929bb0'Slide your finger up to a...']   (Names: '|':_UIBackdropContentView:0x7f9325860000 )>",
        "<NSLayoutConstraint:0x7f932592be50 H:[UILabel:0x7f9325929bb0'Slide your finger up to a...']-(14)-|   (Names: '|':_UIBackdropContentView:0x7f9325860000 )>",
        "<NSLayoutConstraint:0x7f932592b770 H:|-(0)-[_UIBackdropView:0x7f932585e990]   (Names: '|':UIView:0x7f932585e830 )>",
        "<NSLayoutConstraint:0x7f932592b7f0 H:[_UIBackdropView:0x7f932585e990]-(0)-|   (Names: '|':UIView:0x7f932585e830 )>",
        "<NSLayoutConstraint:0x7f932592b450 H:|-(0)-[UIView:0x7f932585e830]   (Names: '|':AVAlphaUpdatingView:0x7f932585e310 )>",
        "<NSLayoutConstraint:0x7f932592b4d0 H:[UIView:0x7f932585e830]-(0)-|   (Names: '|':AVAlphaUpdatingView:0x7f932585e310 )>",
        "<NSLayoutConstraint:0x7f932594aa10 'UIView-Encapsulated-Layout-Width' H:[AVAlphaUpdatingView:0x7f932585e310(0)]>"
    )
    
    Will attempt to recover by breaking constraint 
    <NSLayoutConstraint:0x7f932592be50 H:[UILabel:0x7f9325929bb0'Slide your finger up to a...']-(14)-|   (Names: '|':_UIBackdropContentView:0x7f9325860000 )>
    
    Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
    The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
    2015-09-30 12:58:35.906 AVPlayerTest[9352:446772] 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) 
    (
        "<NSLayoutConstraint:0x7f932592b5e0 V:|-(>=0)-[UIView:0x7f932585e830]   (Names: '|':AVAlphaUpdatingView:0x7f932585e310 )>",
        "<NSLayoutConstraint:0x7f932592b660 V:[UIView:0x7f932585e830]-(0)-|   (Names: '|':AVAlphaUpdatingView:0x7f932585e310 )>",
        "<NSLayoutConstraint:0x7f932592af50 V:[UIView:0x7f932585e830(44)]>",
        "<NSLayoutConstraint:0x7f9325952c30 'UIView-Encapsulated-Layout-Height' V:[AVAlphaUpdatingView:0x7f932585e310(0)]>"
    )
    
    Will attempt to recover by breaking constraint 
    <NSLayoutConstraint:0x7f932592b660 V:[UIView:0x7f932585e830]-(0)-|   (Names: '|':AVAlphaUpdatingView:0x7f932585e310 )>
    
    Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
    The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
    2015-09-30 12:58:35.907 AVPlayerTest[9352:446772] 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:0x7f93259513b0 h=-&- v=-&- _UIBackdropContentView:0x7f9325860000.width == _UIBackdropView:0x7f932585e990.width>",
        "<NSLayoutConstraint:0x7f932592ba00 H:|-(0)-[UIView:0x7f932585fbc0]   (Names: '|':_UIBackdropContentView:0x7f9325860000 )>",
        "<NSLayoutConstraint:0x7f932592ba80 H:[UIView:0x7f932585fbc0]-(0)-|   (Names: '|':_UIBackdropContentView:0x7f9325860000 )>",
        "<NSLayoutConstraint:0x7f932592b770 H:|-(0)-[_UIBackdropView:0x7f932585e990]   (Names: '|':UIView:0x7f932585e830 )>",
        "<NSLayoutConstraint:0x7f932592b7f0 H:[_UIBackdropView:0x7f932585e990]-(0)-|   (Names: '|':UIView:0x7f932585e830 )>",
        "<NSLayoutConstraint:0x7f932592b450 H:|-(0)-[UIView:0x7f932585e830]   (Names: '|':AVAlphaUpdatingView:0x7f932585e310 )>",
        "<NSLayoutConstraint:0x7f932592b4d0 H:[UIView:0x7f932585e830]-(0)-|   (Names: '|':AVAlphaUpdatingView:0x7f932585e310 )>",
        "<NSLayoutConstraint:0x7f932582a040 H:|-(14)-[AVButton:0x7f93258609b0](LTR)   (Names: '|':UIView:0x7f932585fbc0 )>",
        "<NSLayoutConstraint:0x7f9325829f90 H:[AVButton:0x7f93258609b0]-(15)-[UILabel:0x7f932347dc20'--:--'](LTR)>",
        "<NSLayoutConstraint:0x7f9325839550 H:[UILabel:0x7f932347dc20'--:--']-(12)-[AVScrubber:0x7f93234a4350](LTR)>",
        "<NSLayoutConstraint:0x7f932585a2f0 AVScrubber:0x7f93234a4350.right == UILabel:0x7f932583a470'--:--'.left - 12>",
        "<NSLayoutConstraint:0x7f932580b390 UILabel:0x7f932583a470'--:--'.right == AVButton:0x7f932585e480.left - 15>",
        "<NSLayoutConstraint:0x7f932586f490 AVButton:0x7f932585e480.right == AVButton:0x7f93234d1790.left - 10>",
        "<NSLayoutConstraint:0x7f932580b340 AVButton:0x7f93234d1790.right == AVButton:0x7f93234d6540.left - 10>",
        "<NSLayoutConstraint:0x7f932584c870 AVButton:0x7f93234d6540.right == UIView:0x7f932585fbc0.right - 14>",
        "<NSLayoutConstraint:0x7f932594aa10 'UIView-Encapsulated-Layout-Width' H:[AVAlphaUpdatingView:0x7f932585e310(0)]>"
    )
    
    Will attempt to recover by breaking constraint 
    <NSLayoutConstraint:0x7f9325829f90 H:[AVButton:0x7f93258609b0]-(15)-[UILabel:0x7f932347dc20'--:--'](LTR)>
    
    Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
    The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
    2015-09-30 12:58:35.909 AVPlayerTest[9352:446772] 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:0x7f93259513b0 h=-&- v=-&- _UIBackdropContentView:0x7f9325860000.width == _UIBackdropView:0x7f932585e990.width>",
        "<NSLayoutConstraint:0x7f932592ba00 H:|-(0)-[UIView:0x7f932585fbc0]   (Names: '|':_UIBackdropContentView:0x7f9325860000 )>",
        "<NSLayoutConstraint:0x7f932592ba80 H:[UIView:0x7f932585fbc0]-(0)-|   (Names: '|':_UIBackdropContentView:0x7f9325860000 )>",
        "<NSLayoutConstraint:0x7f932592b770 H:|-(0)-[_UIBackdropView:0x7f932585e990]   (Names: '|':UIView:0x7f932585e830 )>",
        "<NSLayoutConstraint:0x7f932592b7f0 H:[_UIBackdropView:0x7f932585e990]-(0)-|   (Names: '|':UIView:0x7f932585e830 )>",
        "<NSLayoutConstraint:0x7f932592b450 H:|-(0)-[UIView:0x7f932585e830]   (Names: '|':AVAlphaUpdatingView:0x7f932585e310 )>",
        "<NSLayoutConstraint:0x7f932592b4d0 H:[UIView:0x7f932585e830]-(0)-|   (Names: '|':AVAlphaUpdatingView:0x7f932585e310 )>",
        "<NSLayoutConstraint:0x7f932582a040 H:|-(14)-[AVButton:0x7f93258609b0](LTR)   (Names: '|':UIView:0x7f932585fbc0 )>",
        "<NSLayoutConstraint:0x7f932586f490 AVButton:0x7f932585e480.right == AVButton:0x7f93234d1790.left - 10>",
        "<NSLayoutConstraint:0x7f932580b340 AVButton:0x7f93234d1790.right == AVButton:0x7f93234d6540.left - 10>",
        "<NSLayoutConstraint:0x7f932584c870 AVButton:0x7f93234d6540.right == UIView:0x7f932585fbc0.right - 14>",
        "<NSLayoutConstraint:0x7f9325859740 H:[AVButton:0x7f93258609b0]-(>=15)-[UILabel:0x7f93234e53f0'Live Broadcast'](LTR)>",
        "<NSLayoutConstraint:0x7f932583bea0 UILabel:0x7f93234e53f0'Live Broadcast'.right <= AVButton:0x7f932585e480.left - 15>",
        "<NSLayoutConstraint:0x7f932594aa10 'UIView-Encapsulated-Layout-Width' H:[AVAlphaUpdatingView:0x7f932585e310(0)]>"
    )
    
    Will attempt to recover by breaking constraint 
    <NSLayoutConstraint:0x7f9325859740 H:[AVButton:0x7f93258609b0]-(>=15)-[UILabel:0x7f93234e53f0'Live Broadcast'](LTR)>
    
    Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
    The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
    2015-09-30 12:58:35.910 AVPlayerTest[9352:446772] 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:0x7f93259513b0 h=-&- v=-&- _UIBackdropContentView:0x7f9325860000.width == _UIBackdropView:0x7f932585e990.width>",
        "<NSLayoutConstraint:0x7f9323520650 H:|-(0)-[UIActivityIndicatorView:0x7f93234e6ee0]   (Names: '|':UIView:0x7f93234e6120 )>",
        "<NSLayoutConstraint:0x7f93235206a0 H:[UIActivityIndicatorView:0x7f93234e6ee0]-(10)-[UILabel:0x7f93235203b0'Loading\U2026']>",
        "<NSLayoutConstraint:0x7f9323520740 H:[UILabel:0x7f93235203b0'Loading\U2026']-(0)-|   (Names: '|':UIView:0x7f93234e6120 )>",
        "<NSLayoutConstraint:0x7f9323521f90 H:|-(>=0)-[UIView:0x7f93234e6120]   (Names: '|':AVLoadingIndicatorView:0x7f93234e5fb0 )>",
        "<NSLayoutConstraint:0x7f9323510da0 UIView:0x7f93234e6120.centerX == AVLoadingIndicatorView:0x7f93234e5fb0.centerX>",
        "<NSLayoutConstraint:0x7f932592ba00 H:|-(0)-[UIView:0x7f932585fbc0]   (Names: '|':_UIBackdropContentView:0x7f9325860000 )>",
        "<NSLayoutConstraint:0x7f932592ba80 H:[UIView:0x7f932585fbc0]-(0)-|   (Names: '|':_UIBackdropContentView:0x7f9325860000 )>",
        "<NSLayoutConstraint:0x7f932592b770 H:|-(0)-[_UIBackdropView:0x7f932585e990]   (Names: '|':UIView:0x7f932585e830 )>",
        "<NSLayoutConstraint:0x7f932592b7f0 H:[_UIBackdropView:0x7f932585e990]-(0)-|   (Names: '|':UIView:0x7f932585e830 )>",
        "<NSLayoutConstraint:0x7f932592b450 H:|-(0)-[UIView:0x7f932585e830]   (Names: '|':AVAlphaUpdatingView:0x7f932585e310 )>",
        "<NSLayoutConstraint:0x7f932592b4d0 H:[UIView:0x7f932585e830]-(0)-|   (Names: '|':AVAlphaUpdatingView:0x7f932585e310 )>",
        "<NSLayoutConstraint:0x7f932582a040 H:|-(14)-[AVButton:0x7f93258609b0](LTR)   (Names: '|':UIView:0x7f932585fbc0 )>",
        "<NSLayoutConstraint:0x7f932586f490 AVButton:0x7f932585e480.right == AVButton:0x7f93234d1790.left - 10>",
        "<NSLayoutConstraint:0x7f932580b340 AVButton:0x7f93234d1790.right == AVButton:0x7f93234d6540.left - 10>",
        "<NSLayoutConstraint:0x7f932584c870 AVButton:0x7f93234d6540.right == UIView:0x7f932585fbc0.right - 14>",
        "<NSLayoutConstraint:0x7f932583bbc0 H:[AVButton:0x7f93258609b0]-(>=15)-[AVLoadingIndicatorView:0x7f93234e5fb0](LTR)>",
        "<NSLayoutConstraint:0x7f932583bc10 AVLoadingIndicatorView:0x7f93234e5fb0.right <= AVButton:0x7f932585e480.left - 15>",
        "<NSLayoutConstraint:0x7f932594aa10 'UIView-Encapsulated-Layout-Width' H:[AVAlphaUpdatingView:0x7f932585e310(0)]>"
    )
    
    Will attempt to recover by breaking constraint 
    <NSLayoutConstraint:0x7f93235206a0 H:[UIActivityIndicatorView:0x7f93234e6ee0]-(10)-[UILabel:0x7f93235203b0'Loading…']>
    
    Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
    The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
    2015-09-30 12:58:35.912 AVPlayerTest[9352:446772] 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:0x7f93259513b0 h=-&- v=-&- _UIBackdropContentView:0x7f9325860000.width == _UIBackdropView:0x7f932585e990.width>",
        "<NSLayoutConstraint:0x7f9323521f90 H:|-(>=0)-[UIView:0x7f93234e6120]   (Names: '|':AVLoadingIndicatorView:0x7f93234e5fb0 )>",
        "<NSLayoutConstraint:0x7f9323510da0 UIView:0x7f93234e6120.centerX == AVLoadingIndicatorView:0x7f93234e5fb0.centerX>",
        "<NSLayoutConstraint:0x7f932592ba00 H:|-(0)-[UIView:0x7f932585fbc0]   (Names: '|':_UIBackdropContentView:0x7f9325860000 )>",
        "<NSLayoutConstraint:0x7f932592ba80 H:[UIView:0x7f932585fbc0]-(0)-|   (Names: '|':_UIBackdropContentView:0x7f9325860000 )>",
        "<NSLayoutConstraint:0x7f932592b770 H:|-(0)-[_UIBackdropView:0x7f932585e990]   (Names: '|':UIView:0x7f932585e830 )>",
        "<NSLayoutConstraint:0x7f932592b7f0 H:[_UIBackdropView:0x7f932585e990]-(0)-|   (Names: '|':UIView:0x7f932585e830 )>",
        "<NSLayoutConstraint:0x7f932592b450 H:|-(0)-[UIView:0x7f932585e830]   (Names: '|':AVAlphaUpdatingView:0x7f932585e310 )>",
        "<NSLayoutConstraint:0x7f932592b4d0 H:[UIView:0x7f932585e830]-(0)-|   (Names: '|':AVAlphaUpdatingView:0x7f932585e310 )>",
        "<NSLayoutConstraint:0x7f932582a040 H:|-(14)-[AVButton:0x7f93258609b0](LTR)   (Names: '|':UIView:0x7f932585fbc0 )>",
        "<NSLayoutConstraint:0x7f932586f490 AVButton:0x7f932585e480.right == AVButton:0x7f93234d1790.left - 10>",
        "<NSLayoutConstraint:0x7f932580b340 AVButton:0x7f93234d1790.right == AVButton:0x7f93234d6540.left - 10>",
        "<NSLayoutConstraint:0x7f932584c870 AVButton:0x7f93234d6540.right == UIView:0x7f932585fbc0.right - 14>",
        "<NSLayoutConstraint:0x7f932583bbc0 H:[AVButton:0x7f93258609b0]-(>=15)-[AVLoadingIndicatorView:0x7f93234e5fb0](LTR)>",
        "<NSLayoutConstraint:0x7f932583bc10 AVLoadingIndicatorView:0x7f93234e5fb0.right <= AVButton:0x7f932585e480.left - 15>",
        "<NSLayoutConstraint:0x7f932594aa10 'UIView-Encapsulated-Layout-Width' H:[AVAlphaUpdatingView:0x7f932585e310(0)]>"
    )
    
    Will attempt to recover by breaking constraint 
    <NSLayoutConstraint:0x7f9323510da0 UIView:0x7f93234e6120.centerX == AVLoadingIndicatorView:0x7f93234e5fb0.centerX>
    
    Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
    The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
    2015-09-30 12:58:35.912 AVPlayerTest[9352:446772] 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:0x7f93259513b0 h=-&- v=-&- _UIBackdropContentView:0x7f9325860000.width == _UIBackdropView:0x7f932585e990.width>",
        "<NSLayoutConstraint:0x7f9323521f90 H:|-(>=0)-[UIView:0x7f93234e6120]   (Names: '|':AVLoadingIndicatorView:0x7f93234e5fb0 )>",
        "<NSLayoutConstraint:0x7f9323510d10 H:[UIView:0x7f93234e6120]-(>=0)-|   (Names: '|':AVLoadingIndicatorView:0x7f93234e5fb0 )>",
        "<NSLayoutConstraint:0x7f932592ba00 H:|-(0)-[UIView:0x7f932585fbc0]   (Names: '|':_UIBackdropContentView:0x7f9325860000 )>",
        "<NSLayoutConstraint:0x7f932592ba80 H:[UIView:0x7f932585fbc0]-(0)-|   (Names: '|':_UIBackdropContentView:0x7f9325860000 )>",
        "<NSLayoutConstraint:0x7f932592b770 H:|-(0)-[_UIBackdropView:0x7f932585e990]   (Names: '|':UIView:0x7f932585e830 )>",
        "<NSLayoutConstraint:0x7f932592b7f0 H:[_UIBackdropView:0x7f932585e990]-(0)-|   (Names: '|':UIView:0x7f932585e830 )>",
        "<NSLayoutConstraint:0x7f932592b450 H:|-(0)-[UIView:0x7f932585e830]   (Names: '|':AVAlphaUpdatingView:0x7f932585e310 )>",
        "<NSLayoutConstraint:0x7f932592b4d0 H:[UIView:0x7f932585e830]-(0)-|   (Names: '|':AVAlphaUpdatingView:0x7f932585e310 )>",
        "<NSLayoutConstraint:0x7f932582a040 H:|-(14)-[AVButton:0x7f93258609b0](LTR)   (Names: '|':UIView:0x7f932585fbc0 )>",
        "<NSLayoutConstraint:0x7f932586f490 AVButton:0x7f932585e480.right == AVButton:0x7f93234d1790.left - 10>",
        "<NSLayoutConstraint:0x7f932580b340 AVButton:0x7f93234d1790.right == AVButton:0x7f93234d6540.left - 10>",
        "<NSLayoutConstraint:0x7f932584c870 AVButton:0x7f93234d6540.right == UIView:0x7f932585fbc0.right - 14>",
        "<NSLayoutConstraint:0x7f932583bbc0 H:[AVButton:0x7f93258609b0]-(>=15)-[AVLoadingIndicatorView:0x7f93234e5fb0](LTR)>",
        "<NSLayoutConstraint:0x7f932583bc10 AVLoadingIndicatorView:0x7f93234e5fb0.right <= AVButton:0x7f932585e480.left - 15>",
        "<NSLayoutConstraint:0x7f932594aa10 'UIView-Encapsulated-Layout-Width' H:[AVAlphaUpdatingView:0x7f932585e310(0)]>"
    )
    
    Will attempt to recover by breaking constraint 
    <NSLayoutConstraint:0x7f9323510d10 H:[UIView:0x7f93234e6120]-(>=0)-|   (Names: '|':AVLoadingIndicatorView:0x7f93234e5fb0 )>
    
    Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
    The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
    2015-09-30 12:58:35.913 AVPlayerTest[9352:446772] 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:0x7f93259513b0 h=-&- v=-&- _UIBackdropContentView:0x7f9325860000.width == _UIBackdropView:0x7f932585e990.width>",
        "<NSLayoutConstraint:0x7f932592ba00 H:|-(0)-[UIView:0x7f932585fbc0]   (Names: '|':_UIBackdropContentView:0x7f9325860000 )>",
        "<NSLayoutConstraint:0x7f932592ba80 H:[UIView:0x7f932585fbc0]-(0)-|   (Names: '|':_UIBackdropContentView:0x7f9325860000 )>",
        "<NSLayoutConstraint:0x7f932592b770 H:|-(0)-[_UIBackdropView:0x7f932585e990]   (Names: '|':UIView:0x7f932585e830 )>",
        "<NSLayoutConstraint:0x7f932592b7f0 H:[_UIBackdropView:0x7f932585e990]-(0)-|   (Names: '|':UIView:0x7f932585e830 )>",
        "<NSLayoutConstraint:0x7f932592b450 H:|-(0)-[UIView:0x7f932585e830]   (Names: '|':AVAlphaUpdatingView:0x7f932585e310 )>",
        "<NSLayoutConstraint:0x7f932592b4d0 H:[UIView:0x7f932585e830]-(0)-|   (Names: '|':AVAlphaUpdatingView:0x7f932585e310 )>",
        "<NSLayoutConstraint:0x7f932582a040 H:|-(14)-[AVButton:0x7f93258609b0](LTR)   (Names: '|':UIView:0x7f932585fbc0 )>",
        "<NSLayoutConstraint:0x7f932586f490 AVButton:0x7f932585e480.right == AVButton:0x7f93234d1790.left - 10>",
        "<NSLayoutConstraint:0x7f932580b340 AVButton:0x7f93234d1790.right == AVButton:0x7f93234d6540.left - 10>",
        "<NSLayoutConstraint:0x7f932584c870 AVButton:0x7f93234d6540.right == UIView:0x7f932585fbc0.right - 14>",
        "<NSLayoutConstraint:0x7f932583bbc0 H:[AVButton:0x7f93258609b0]-(>=15)-[AVLoadingIndicatorView:0x7f93234e5fb0](LTR)>",
        "<NSLayoutConstraint:0x7f932583bc10 AVLoadingIndicatorView:0x7f93234e5fb0.right <= AVButton:0x7f932585e480.left - 15>",
        "<NSLayoutConstraint:0x7f932594aa10 'UIView-Encapsulated-Layout-Width' H:[AVAlphaUpdatingView:0x7f932585e310(0)]>"
    )
    
    Will attempt to recover by breaking constraint 
    <NSLayoutConstraint:0x7f932583bbc0 H:[AVButton:0x7f93258609b0]-(>=15)-[AVLoadingIndicatorView:0x7f93234e5fb0](LTR)>
    
    Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
    The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
    

    对于漫长的日志感到抱歉,但所有内容都会立即出现,包括它。 我错过了什么?自动布局工作得很好。即使在轮换。为什么我会看到这些警告?

    添加了Sample Project

    P.S。:使用Xcode 7.0版

    更新

    取消选中属性检查器中Shows Playback Controls上的AVPlayerViewController会以某种方式修复它,我看不到任何警告。但我需要控制。似乎越来越像一个错误。

6 个答案:

答案 0 :(得分:27)

事实上,我认为这是Apple方面的错误。

我找到了一个解决方法:在设置AVPlayerViewController.player后将showsPlaybackControls设置为YES。

我使用以下行修改您的示例,不再出现Constraint错误:

@interface ViewController ()

@property(weak, nonatomic) AVPlayerViewController * playerViewController;


@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    NSString *path = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"mp4"];
    NSURL *url = [[NSURL alloc] initFileURLWithPath: path];
    AVPlayer * player = [AVPlayer playerWithURL:url];

    self.playerViewController.player = player;
    self.playerViewController.showsPlaybackControls = YES;
}


- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    if ([segue.identifier isEqualToString:@"AVPlayerSegue"]) {
        self.playerViewController = segue.destinationViewController;
    }
}


@end

请注意,文件test.mp4已添加到项目中。

答案 1 :(得分:1)

我下载了您的代码并查看了它。你没有做错任何事。您可以取消选中&#34;显示播放控制&#34;似乎表明问题在于AVKit框架。我甚至尝试在XIB文件中将值设置为false,然后在[self setShowsPlaybackControls:YES];之后调用viewDidAppear:并获得相同的结果。这绝对是一个Apple bug,你应该提出一个bug报告。

答案 2 :(得分:1)

在我的情况下,我只允许在iPhone上使用纵向模式,而我希望AVPlayerViewController拥有所有路线。

AppDelegate中我的代码如下所示:

public func application(application: UIApplication, supportedInterfaceOrientationsForWindow window: UIWindow?) -> UIInterfaceOrientationMask {

    if self.window?.rootViewController?.presentedViewController is AVPlayerViewController {

        return .All
    }
    return Device.current.contains(.iPhone) ? [.Portrait, .PortraitUpsideDown] : .All
}

AVPlayerViewController以模态方式呈现,旋转到横向并被解雇时,我会得到一个非常微笑的错误堆栈,其中一些约束已经破坏。

要解决此问题,我将此代码添加到我的RootViewController,该代码还在我的应用程序中显示AVPlayerViewController的任何实例:

public override func dismissViewControllerAnimated(flag: Bool, completion: (() -> Void)?) {

    if let playerViewController = self.presentedViewController as? AVPlayerViewController {

        playerViewController.showsPlaybackControls = false
    }

    super.dismissViewControllerAnimated(flag, completion: completion)
}

基本上我抓住了用户点击关闭按钮并使用原始问题帖子中找到的解决方法的那一刻。

答案 3 :(得分:1)

不幸的是,ios 10.1中仍然存在此错误。 无论如何,我观察到如果我将seekTime设置为0来呈现视图控制器,则该bug不存在。 所以,我的解决方案是暂停播放器,保持当前时间,寻找播放器为0,呈现控制器并在完成时执行以下操作:寻找保留时间并再次播放。

AVPlayer *player;
AVPlayerViewController *avPlayerController;
CMTime currentTime;

- (void)viewDidLoad {
    [super viewDidLoad];

    NSURL *videoURL = [NSURL URLWithString:@"https://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"];
    player = [AVPlayer playerWithURL:videoURL];
    AVPlayerLayer *playerLayer = [AVPlayerLayer playerLayerWithPlayer:player];
    [self.playerView.layer addSublayer:playerLayer];
    playerLayer.frame = self.playerView.bounds;
    avPlayerController = [[AVPlayerViewController alloc] init];
    avPlayerController.player = player;

}

- (IBAction)fullScreen:(id)sender {
    [player pause];
    currentTime = player.currentTime;
    [player seekToTime:CMTimeMake(0, 1)];

    [self presentViewController:avPlayerController animated:YES completion:^{
        [avPlayerController.player seekToTime:currentTime];
        [avPlayerController.player play];
    }];
}

答案 4 :(得分:0)

我意识到当你尝试呈现相同的AVPlayerViewController实例(使用强引用属性)时,第二次,第三次......等时间并且播放器控件未重置(即进度不在开头)

Progress bar not in 0:00

实际上,如果您正面临相同的情况,在点击“完成”之前,请尝试将进度条拖动到开头并再次显示AVPlayerViewController。然后自动布局问题应该消失!

因此,如果在解除AVPlayerViewController之前重置控件,基本上可以修复Autolayout问题(顺便说一下Apple问题)。但是,如果您想要呈现相同的视频怎么办?在我的情况下,我想保留对AVPlayerItem的引用:

@property (strong, nonatomic) AVPlayerItem *playerItem;

但我不希望发生这种崩溃:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'An AVPlayerItem cannot be associated with more than one instance of AVPlayer'
*** First throw call stack:
(0x184035900 0x1836a3f80 0x18a254958 0x18a23fc14 0x100054a2c 0x188d5fe50 0x188d5fdcc 0x188d47a88 0x188d5f6e4 0x188d18294 0x188d58820 0x188d57e1c 0x188d284cc 0x188d26794 0x183fecefc 0x183fec990 0x183fea690 0x183f19680 0x185428088 0x188d90d90 0x1000eea78 0x183aba8b8)
libc++abi.dylib: terminating with uncaught exception of type NSException

所以我的解决方法是每次推送AVPlayerViewController时创建AVPLayerItem的副本。这样,崩溃和自动布局问题就消失了。但是,每次推动播放器时都会重置视频。

AVPlayerViewController *playerViewController = [AVPlayerViewController new];
playerViewController.player = [[AVPlayer alloc] initWithPlayerItem:self.playerItem.copy];

答案 5 :(得分:-1)

此警告表示您使用了一个不需要使用的额外约束。

ToolBarHeight 默认为 44 ,对于您使用UIToolBar高度限制的所有iphone设备。因此工具栏高度约束在这里是额外的,删除此约束警告将自动删除