抑制AVPlayerViewController布局错误

时间:2018-04-07 13:15:28

标签: swift logging avplayerviewcontroller avkit

我正在使用AVPlayerViewController:

func play(url:URL, parent:UIViewController) {
    let player = AVPlayer(url: url)
    NotificationCenter.default.addObserver(self, selector: #selector(AVPlayerManager.didfinishplaying(note:)), name:NSNotification.Name.AVPlayerItemDidPlayToEndTime, object: player.currentItem)
    playerController.player=player
    playerController.allowsPictureInPicturePlayback = false
    playerController.showsPlaybackControls = true
    playerController.delegate = self
    playerController.player?.play()
    parent.present(playerController,animated:true,completion:nil)
}

我有一个扩展名:

@objc func didfinishplaying(note : NSNotification)
{
    playerController.dismiss(animated: true,completion: nil)
}

在日志中我看到了:

2018-04-07 07:59:51.151973-0500 YourAppName[679:533213] [LayoutConstraints] 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. 
(
"<NSLayoutConstraint:0x1c4099e10 'UISV-canvas-connection' UILayoutGuide:0x1c41ac160'UIViewLayoutMarginsGuide'.leading == _UILayoutSpacer:0x1c41d0860'UISV-ordering-spanner'.leading   (active)>",
"<NSLayoutConstraint:0x1c4099dc0 'UISV-canvas-connection' UILayoutGuide:0x1c41ac160'UIViewLayoutMarginsGuide'.trailing == _UILayoutSpacer:0x1c41d0860'UISV-ordering-spanner'.trailing   (active)>",
"<NSLayoutConstraint:0x1c409a630 'UIView-Encapsulated-Layout-Width' UIStackView:0x10425b610.width == 0   (active)>",
"<NSLayoutConstraint:0x1c409a220 'UIView-leftMargin-guide-constraint' H:|-(12)-[UILayoutGuide:0x1c41ac160'UIViewLayoutMarginsGuide'](LTR)   (active, names: '|':UIStackView:0x10425b610 )>",
"<NSLayoutConstraint:0x1c409a1d0 'UIView-rightMargin-guide-constraint' H:[UILayoutGuide:0x1c41ac160'UIViewLayoutMarginsGuide']-(12)-|(LTR)   (active, names: '|':UIStackView:0x10425b610 )>")
Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x1c4099dc0 'UISV-canvas-connection' UILayoutGuide:0x1c41ac160'UIViewLayoutMarginsGuide'.trailing == _UILayoutSpacer:0x1c41d0860'UISV-ordering-spanner'.trailing   (active)>
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.

是否可以采取任何措施来防止生成这些日志消息,或者它们是否实际指向了某些问题?

0 个答案:

没有答案