У меня есть ViewController с UIWebView, который загружает видео с YouTube.Когда я пытаюсь посмотреть видео в полноэкранном режиме, я получаю ошибки ограничения.Видео воспроизводится нормально, если оно не полноэкранное.Когда я нажимаю на полноэкранную кнопку, видео переходит в полноэкранный режим на долю секунды, а затем возвращается в обычный режим и перезапускает видео с самого начала.Не уверен, почему я получаю эти ошибки.
Вот мой класс ViewController:
class VideoViewController: UIViewController {
private var webView: UIWebView!
var videoId: String? = "4YpZg-XpdAY"
override func viewDidLoad() {
super.viewDidLoad()
webView = UIWebView()
webView.allowsInlineMediaPlayback = true
webView.translatesAutoresizingMaskIntoConstraints = true
view.addSubview(webView)
}
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
if let url = URL(string: "https://www.youtube.com/watch?v=\(videoId!)") {
webView.loadRequest(URLRequest(url: url))
}
view.addConstraintsWithFormat(format: "H:|[v0]|", views: webView)
view.addConstraintsWithFormat(format: "V:|[v0]|", views: webView)
}
}
Ошибка, которую я получаю в консоли:
2018-10-16 02:02:21.662220-0400 Logic[2845:38866] [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.
(Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)
(
"<NSAutoresizingMaskLayoutConstraint:0x604000290040 h=-&- v=-&- AVPlaybackControlsView:0x7fd920c88770.width == AVPlayerViewControllerContentView:0x7fd92317b2a0.width (active)>",
"<NSAutoresizingMaskLayoutConstraint:0x60c000094870 h=-&- v=-&- AVPlayerViewControllerContentView:0x7fd92317b2a0.width == UIView:0x7fd920e6e490.width (active)>",
"<NSLayoutConstraint:0x60c0000975c0 AVBackdropView:0x7fd920c89db0.leading == UILayoutGuide:0x60c0001b81e0'UIViewLayoutMarginsGuide'.leading (active)>",
"<NSLayoutConstraint:0x60c000097660 AVBackdropView:0x7fd920c8d9d0.trailing == UILayoutGuide:0x60c0001b81e0'UIViewLayoutMarginsGuide'.trailing (active)>",
"<NSLayoutConstraint:0x60c000097980 H:[AVBackdropView:0x7fd920c89db0]-(>=11)-[AVBackdropView:0x7fd920c8d9d0] (active)>",
"<NSLayoutConstraint:0x60c000099140 'UIView-Encapsulated-Layout-Width' UIView:0x7fd920e6e490.width == 0 (active)>",
"<NSLayoutConstraint:0x60c000097430 'UIView-leftMargin-guide-constraint' H:|-(6)-[UILayoutGuide:0x60c0001b81e0'UIViewLayoutMarginsGuide'](LTR) (active, names: '|':AVPlaybackControlsView:0x7fd920c88770 )>",
"<NSLayoutConstraint:0x60c0000974d0 'UIView-rightMargin-guide-constraint' H:[UILayoutGuide:0x60c0001b81e0'UIViewLayoutMarginsGuide']-(6)-|(LTR) (active, names: '|':AVPlaybackControlsView:0x7fd920c88770 )>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x60c000097980 H:[AVBackdropView:0x7fd920c89db0]-(>=11)-[AVBackdropView:0x7fd920c8d9d0] (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.
2018-10-16 02:02:21.663574-0400 Logic[2845:38866] [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.
(Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)
(
"<NSAutoresizingMaskLayoutConstraint:0x604000290040 h=-&- v=-&- AVPlaybackControlsView:0x7fd920c88770.width == AVPlayerViewControllerContentView:0x7fd92317b2a0.width (active)>",
"<NSAutoresizingMaskLayoutConstraint:0x60c000094870 h=-&- v=-&- AVPlayerViewControllerContentView:0x7fd92317b2a0.width == UIView:0x7fd920e6e490.width (active)>",
"<NSLayoutConstraint:0x60c000097160 AVView:0x7fd920c8b170.width == AVTransportControlsView:0x7fd920c8b7b0.width (active)>",
"<NSLayoutConstraint:0x60c000097840 AVView:0x7fd920c8b170.width <= AVPlaybackControlsView:0x7fd920c88770.width (active)>",
"<NSLayoutConstraint:0x600000281040 AVBackdropView:0x7fd92318cc10.width <= AVTransportControlsView:0x7fd920c8b7b0.width (active)>",
"<NSLayoutConstraint:0x600000281450 H:|-(16)-[Time Elapsed](LTR) (active, names: Time Elapsed:0x7fd923134e60, '|':AVBackdropView:0x7fd92318cc10 )>",
"<NSLayoutConstraint:0x6000002814a0 Time Remaining.right == AVBackdropView:0x7fd92318cc10.right - 16 (active, names: Time Remaining:0x7fd920c460d0 )>",
"<NSLayoutConstraint:0x6000002815e0 AVScrubber:0x7fd920c8beb0.left == Time Elapsed.left (active, names: Time Elapsed:0x7fd923134e60 )>",
"<NSLayoutConstraint:0x600000281630 AVScrubber:0x7fd920c8beb0.right == Time Remaining.right (active, names: Time Remaining:0x7fd920c460d0 )>",
"<NSLayoutConstraint:0x60c000099140 'UIView-Encapsulated-Layout-Width' UIView:0x7fd920e6e490.width == 0 (active)>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x600000281630 AVScrubber:0x7fd920c8beb0.right == Time Remaining.right (active, names: Time Remaining:0x7fd920c460d0 )>
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.