Swift 4 UIWebView Video Fullscreen Constraints error - ios

I have a ViewController with a UIWebView, that loads a Youtube video. When I try to watch the video in fullscreen mode I get constraint errors. The video plays fine if it's not fullscreen. When I press on the fullscreen button, the video goes to fullscreen for a split second and then go back to normal mode and restart the video from the beginning. Not sure why I'm getting these errors.
Here is my ViewController class:
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)
}
}
Error I'm getting in Console:
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.

Try this
var videoID: String? = "4YpZg-XpdAY"
guard let youtubeURL = URL(string: "https://www.youtube.com/embed/\(videoID)?rel=0&controls=0&showinfo=0&autoplay=1&allowfullscreen=1")
else { return }
webView.allowsInlineMediaPlayback = false
webView.mediaPlaybackRequiresUserAction = false
webView.mediaPlaybackAllowsAirPlay = true
webView.loadRequest( URLRequest(url: youtubeURL) )

Related

How to add constrains inside custom UIView?

I want to add constrainst to UILabel
My custom UIView class:
class LabelView: UIView {
public var label: UILabel = UILabel()
override init(frame: CGRect) {
super.init(frame: frame)
self.frame = frame
prepareUI()
}
func prepareUI() {
self.label.text = "SOME TEXT"
self.label.sizeToFit()
self.label.adjustsFontSizeToFitWidth = true
self.label.textAlignment = .center
self.addSubview(self.label)
self.translatesAutoresizingMaskIntoConstraints = false
self.label.centerXAnchor.constraint(equalTo: self.centerXAnchor).isActive = true
self.label.centerYAnchor.constraint(equalTo: self.centerYAnchor).isActive = true
self.label.widthAnchor.constraint(equalTo: self.widthAnchor, multiplier: 0.5).isActive = true
self.label.heightAnchor.constraint(equalTo: self.heightAnchor, multiplier: 0.2).isActive = true
}
}
after running I get the following error and the UILabel is placed in the top left corner of the UIView:
2021-02-13 02:32:26.698694+1000 SwiftHello[96793:1625524] [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:0x600000606c10 h=--& v=--& UILabel:0x142616930.minX == 0 (active, names: '|':SwiftHello.LabelView:0x1426167c0 )>",
"<NSAutoresizingMaskLayoutConstraint:0x600000606c60 h=--& v=--& UILabel:0x142616930.width == 93.5 (active)>",
"<NSLayoutConstraint:0x6000006061c0 UILabel:0x142616930.centerX == SwiftHello.LabelView:0x1426167c0.centerX (active)>",
"<NSLayoutConstraint:0x600000606300 UILabel:0x142616930.width == 0.5*SwiftHello.LabelView:0x1426167c0.width (active)>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x6000006061c0 UILabel:0x142616930.centerX == SwiftHello.LabelView:0x1426167c0.centerX (active)>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.
2021-02-13 02:32:26.698920+1000 SwiftHello[96793:1625524] [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:0x600000606cb0 h=--& v=--& UILabel:0x142616930.minY == 0 (active, names: '|':SwiftHello.LabelView:0x1426167c0 )>",
"<NSAutoresizingMaskLayoutConstraint:0x600000606d00 h=--& v=--& UILabel:0x142616930.height == 20.5 (active)>",
"<NSLayoutConstraint:0x6000006062b0 UILabel:0x142616930.centerY == SwiftHello.LabelView:0x1426167c0.centerY (active)>",
"<NSLayoutConstraint:0x600000606350 UILabel:0x142616930.height == 0.2*SwiftHello.LabelView:0x1426167c0.height (active)>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x6000006062b0 UILabel:0x142616930.centerY == SwiftHello.LabelView:0x1426167c0.centerY (active)>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.
2021-02-13 02:32:26.702639+1000 SwiftHello[96793:1625524] [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:0x600000606c60 h=--& v=--& UILabel:0x142616930.width == 93.5 (active)>",
"<NSLayoutConstraint:0x600000606300 UILabel:0x142616930.width == 0.5SwiftHello.LabelView:0x1426167c0.width (active)>",
"<NSLayoutConstraint:0x600000606940 SwiftHello.LabelView:0x1426167c0.width == 0.85UIView:0x14260e930.width (active)>",
"<NSLayoutConstraint:0x600000606da0 'UIView-Encapsulated-Layout-Width' UIView:0x14260e930.width == 375 (active)>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x600000606300 UILabel:0x142616930.width == 0.5*SwiftHello.LabelView:0x1426167c0.width (active)>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.
2021-02-13 02:32:26.702816+1000 SwiftHello[96793:1625524] [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:0x600000606d00 h=--& v=--& UILabel:0x142616930.height == 20.5 (active)>",
"<NSLayoutConstraint:0x600000606350 UILabel:0x142616930.height == 0.2SwiftHello.LabelView:0x1426167c0.height (active)>",
"<NSLayoutConstraint:0x600000606990 SwiftHello.LabelView:0x1426167c0.height == 0.1UIView:0x14260e930.height (active)>",
"<NSLayoutConstraint:0x600000606d50 'UIView-Encapsulated-Layout-Height' UIView:0x14260e930.height == 667 (active)>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x600000606350 UILabel:0x142616930.height == 0.2*SwiftHello.LabelView:0x1426167c0.height (active)>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.
You're missing this line:
self.label.translatesAutoresizingMaskIntoConstraints = false
You've set it on self but not on the label.

iOS UITableViewCell with UIContextMenuConfiguration: Unable to simultaneously satisfy constraints

I followed this tutorial of raywenderlich.com to display a context menu when long pressing on a UITableViewCell and came up with the following simplified version to test the implementation:
import UIKit
class ViewController: UITableViewController {
override func tableView(
_ tableView: UITableView,
contextMenuConfigurationForRowAt indexPath: IndexPath, point: CGPoint)
-> UIContextMenuConfiguration? {
let identifier = "\(indexPath.row)" as NSString
return UIContextMenuConfiguration(
identifier: identifier,
previewProvider: nil) { _ in
let shareAction = UIAction(
title: "Share",
image: UIImage(systemName: "square.and.arrow.up")) { _ in
print("share")
}
return UIMenu(title: "", image: nil, children: [shareAction])
}
}
}
The ViewController is a plain UITableViewController with Static Cells in the Storyboard. When I run the application and long press the table cell then the code works as expected, but I get the following AutoLayout errors in the console and I do not understand why?
2020-07-06 15:22:36.879780+0200 Test[1033:453998] [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:0x282308780 h=--& v=--& UIInterfaceActionGroupView:0x102833490.width == 0 (active)>",
"<NSLayoutConstraint:0x28231bca0 UILabel:0x102921c50'Share Item'.leading == UILayoutGuide:0x283939420'UIViewLayoutMarginsGuide'.leading (active)>",
"<NSLayoutConstraint:0x28231bcf0 UILabel:0x102921c50'Share Item'.trailing == UILayoutGuide:0x283939420'UIViewLayoutMarginsGuide'.trailing (active)>",
"<NSLayoutConstraint:0x282315db0 _UIInterfaceActionGroupHeaderScrollView:0x103063600.width == _UIPreviewPlatterActionsTitleView:0x102921590'Share Item'.width (active)>",
"<NSLayoutConstraint:0x28231a800 H:|-(0)-[_UIContentConstraintsLayoutGuide:0x1028336f0''] (active, names: '|':UIInterfaceActionGroupView:0x102833490 )>",
"<NSLayoutConstraint:0x28231a850 _UIContentConstraintsLayoutGuide:0x1028336f0''.trailing == UIInterfaceActionGroupView:0x102833490.trailing (active)>",
"<NSLayoutConstraint:0x28232fd40 _UIInterfaceActionGroupHeaderScrollView:0x103063600.width == _UIContentConstraintsLayoutGuide:0x1028336f0''.width (active)>",
"<NSLayoutConstraint:0x28231cfa0 'UIView-leftMargin-guide-constraint' H:|-(12)-[UILayoutGuide:0x283939420'UIViewLayoutMarginsGuide'](LTR) (active, names: '|':_UIPreviewPlatterActionsTitleView:0x102921590'Share Item' )>",
"<NSLayoutConstraint:0x28231bc50 'UIView-rightMargin-guide-constraint' H:[UILayoutGuide:0x283939420'UIViewLayoutMarginsGuide']-(12)-|(LTR) (active, names: '|':_UIPreviewPlatterActionsTitleView:0x102921590'Share Item' )>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x28231bcf0 UILabel:0x102921c50'Share Item'.trailing == UILayoutGuide:0x283939420'UIViewLayoutMarginsGuide'.trailing (active)>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.
2020-07-06 15:22:36.881528+0200 Test[1033:453998] [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:0x2823088c0 h=--& v=--& UIInterfaceActionGroupView:0x102833490.height == 0 (active)>",
"<NSLayoutConstraint:0x28231b070 groupView.actionsSequence....height >= 44 (active, names: groupView.actionsSequence...:0x103062e00 )>",
"<NSLayoutConstraint:0x2823135c0 V:[_UIInterfaceActionGroupHeaderScrollView:0x103063600]-(0)-[_UIInterfaceActionVibrantSeparatorView:0x10283ab40] (active)>",
"<NSLayoutConstraint:0x2823140a0 V:[_UIInterfaceActionVibrantSeparatorView:0x10283ab40]-(0)-[groupView.actionsSequence...] (active, names: groupView.actionsSequence...:0x103062e00 )>",
"<NSLayoutConstraint:0x28231ada0 UIInterfaceActionGroupView:0x102833490.top == _UIContentConstraintsLayoutGuide:0x1028336f0''.top (active)>",
"<NSLayoutConstraint:0x28231adf0 V:[_UIContentConstraintsLayoutGuide:0x1028336f0'']-(0)-| (active, names: '|':UIInterfaceActionGroupView:0x102833490 )>",
"<NSLayoutConstraint:0x282314190 _UIInterfaceActionGroupHeaderScrollView:0x103063600.top == _UIContentConstraintsLayoutGuide:0x1028336f0''.top (active)>",
"<NSLayoutConstraint:0x2823141e0 groupView.actionsSequence....bottom == _UIContentConstraintsLayoutGuide:0x1028336f0''.bottom (active, names: groupView.actionsSequence...:0x103062e00 )>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x28231b070 groupView.actionsSequence....height >= 44 (active, names: groupView.actionsSequence...:0x103062e00 )>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.

Autolayout warning when using prompt in navigation bar

I am using a navigation bar with a prompt, looking like this:
I receive the following auto layout warnings in the console:
2019-09-01 21:26:03.225576+0200 Hortus[85622:2386450] [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:0x600002d16990 UILabel:0x7fc9eb816f50'Testen'.centerX == _UINavigationBarModernPromptView:0x7fc9ebe27780.centerX (active)>",
"<NSLayoutConstraint:0x600002d15c20 UILabel:0x7fc9eb816f50'Testen'.leading >= UILayoutGuide:0x6000037571e0'UIViewLayoutMarginsGuide'.leading (active)>",
"<NSLayoutConstraint:0x600002d10ff0 '_UITemporaryLayoutWidth' _UINavigationBarModernPromptView:0x7fc9ebe27780.width == 0 (active)>",
"<NSLayoutConstraint:0x600002d16a30 'UIView-leftMargin-guide-constraint' H:|-(8)-[UILayoutGuide:0x6000037571e0'UIViewLayoutMarginsGuide'](LTR) (active, names: '|':_UINavigationBarModernPromptView:0x7fc9ebe27780 )>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x600002d15c20 UILabel:0x7fc9eb816f50'Testen'.leading >= UILayoutGuide:0x6000037571e0'UIViewLayoutMarginsGuide'.leading (active)>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.
2019-09-01 21:26:03.226198+0200 Hortus[85622:2386450] [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:0x600002d16990 UILabel:0x7fc9eb816f50'Testen'.centerX == _UINavigationBarModernPromptView:0x7fc9ebe27780.centerX (active)>",
"<NSLayoutConstraint:0x600002d15540 UILabel:0x7fc9eb816f50'Testen'.trailing <= UILayoutGuide:0x6000037571e0'UIViewLayoutMarginsGuide'.trailing (active)>",
"<NSLayoutConstraint:0x600002d10ff0 '_UITemporaryLayoutWidth' _UINavigationBarModernPromptView:0x7fc9ebe27780.width == 0 (active)>",
"<NSLayoutConstraint:0x600002d14320 'UIView-rightMargin-guide-constraint' H:[UILayoutGuide:0x6000037571e0'UIViewLayoutMarginsGuide']-(8)-|(LTR) (active, names: '|':_UINavigationBarModernPromptView:0x7fc9ebe27780 )>"
"<NSAutoresizingMaskLayoutConstraint:0x60000043be30 h=--& v=--& _UINavigationBarModernPromptView:0x7fb3c6416640.width == 0 (active)>",
"<NSLayoutConstraint:0x600000421400 UILabel:0x7fb3c66d8bf0'Plant guide'.centerX == _UINavigationBarModernPromptView:0x7fb3c6416640.centerX (active)>",
"<NSLayoutConstraint:0x600000421f90 UILabel:0x7fb3c66d8bf0'Plant guide'.trailing <= UILayoutGuide:0x600001e58fc0'UIViewLayoutMarginsGuide'.trailing (active)>",
"<NSLayoutConstraint:0x600000421e00 'UIView-rightMargin-guide-constraint' H:[UILayoutGuide:0x600001e58fc0'UIViewLayoutMarginsGuide']-(20)-|(LTR) (active, names: '|':_UINavigationBarModernPromptView:0x7fb3c6416640 )>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x600002d15540 UILabel:0x7fc9eb816f50'Testen'.trailing <= UILayoutGuide:0x6000037571e0'UIViewLayoutMarginsGuide'.trailing (active)>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.
These warnings are given for the prompt in the navigation bar, but I do not set the autolayout constraints for the navigation bar. This should be handled by IOS itself.
What can I do to fix these warnings?
[Edit] The warnings are given in prepare() when segueing to the view controller. I set the prompt in prepare(). The segue is to a storyboard reference and is defined as 'present modally'. The storyboard reference references a UINavigationController. The prompt is set on the root view controller of the navigation controller.
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if let identifier = segue.identifier {
switch identifier {
case "editImage":
let nc = segue.destination as? TTImageNavigationController
if let rvc = nc?.rootViewController as? TTImageEditorController {
rvc.navigationItem.prompt = navigationItem.prompt
}
default:
break
}
}
}
[EDIT] It seems that the problem is not clear to most of the people who react. Again... I do not set any auto layout settings in code or storyboard. The problem occurs in the navigation bar after setting the prompt in the prepare() function prior to the segue. The code is given above. Any reactions that say that I have to change or check my constraints are not helpful, because there are no constraints to check!
[EDIT] As requested by Mohsen, I created a small sample project on github: https://bitbucket.org/Leontien/navigationbarautolayoutwarning/src/master/
It’s not your bug. It’s Apple’s bug. Ignore the console. File a report with Apple and move on.
Set priority to your constraints. This will fulfill constraints according to priority. Please refer this link.
you set centerX for the label and set leading and trailing for right and left buttons, also you didn't set any width constraint for UILabel
"<NSLayoutConstraint:0x600002d16990 UILabel:0x7fc9eb816f50'Testen'.centerX == _UINavigationBarModernPromptView:0x7fc9ebe27780.centerX (active)>",
"<NSLayoutConstraint:0x600002d15c20 UILabel:0x7fc9eb816f50'Testen'.leading >= UILayoutGuide:0x6000037571e0'UIViewLayoutMarginsGuide'.leading (active)>",
"<NSLayoutConstraint:0x600002d10ff0 '_UITemporaryLayoutWidth' _UINavigationBarModernPromptView:0x7fc9ebe27780.width == 0 (active)>",
"<NSLayoutConstraint:0x600002d16a30 'UIView-leftMargin-guide-constraint' H:|-(8)-[UILayoutGuide:0x6000037571e0'UIViewLayoutMarginsGuide'](LTR) (active, names: '|':_UINavigationBarModernPromptView:0x7fc9ebe27780 )>"
.
"<NSLayoutConstraint:0x600002d16990 UILabel:0x7fc9eb816f50'Testen'.centerX == _UINavigationBarModernPromptView:0x7fc9ebe27780.centerX (active)>",
"<NSLayoutConstraint:0x600002d15540 UILabel:0x7fc9eb816f50'Testen'.trailing <= UILayoutGuide:0x6000037571e0'UIViewLayoutMarginsGuide'.trailing (active)>",
"<NSLayoutConstraint:0x600002d10ff0 '_UITemporaryLayoutWidth' _UINavigationBarModernPromptView:0x7fc9ebe27780.width == 0 (active)>",
"<NSLayoutConstraint:0x600002d14320 'UIView-rightMargin-guide-constraint' H:[UILayoutGuide:0x6000037571e0'UIViewLayoutMarginsGuide']-(8)-|(LTR) (active, names: '|':_UINavigationBarModernPromptView:0x7fc9ebe27780 )>"
"<NSAutoresizingMaskLayoutConstraint:0x60000043be30 h=--& v=--& _UINavigationBarModernPromptView:0x7fb3c6416640.width == 0 (active)>",
"<NSLayoutConstraint:0x600000421400 UILabel:0x7fb3c66d8bf0'Plant guide'.centerX == _UINavigationBarModernPromptView:0x7fb3c6416640.centerX (active)>",
"<NSLayoutConstraint:0x600000421f90 UILabel:0x7fb3c66d8bf0'Plant guide'.trailing <= UILayoutGuide:0x600001e58fc0'UIViewLayoutMarginsGuide'.trailing (active)>",
"<NSLayoutConstraint:0x600000421e00 'UIView-rightMargin-guide-constraint' H:[UILayoutGuide:0x600001e58fc0'UIViewLayoutMarginsGuide']-(20)-|(LTR) (active, names: '|':_UINavigationBarModernPromptView:0x7fb3c6416640 )>"
for solve this warning you should remove leading and trailing constraint from UILabel and set left button with leading to superview and right button's trailing to superview as well.
or you can use a navigation bar object, it has a label and also you can add barButtonItem to it.
you can add width constraint for the UILabel but it will be conflict on another devices when you run it on some other devices
This helps to debug broken constraint issue by providing a more readable output
Create an extension for NSLayoutConstraint
extension NSLayoutConstraint {
override open var description: String {
let id = identifier ?? ""
return "Constraint ID: \(id), constant: \(constant)"
}
}
set a unique identifier for every constraint in the storyboard
you'll get a more readable output pointing out which constraint id is broken
change the priority for broken constraint

UIView is behind translucent navigation bar with pragmatically created view constraints

I have a function that inserts a generic UIView into a view controller at the top of the view and I would like for the inserted view to be at the bottom of a navigation bar, or if there isn't one, at the bottom of the status bar.
I assumed that the view controllers top layout guide would update automatically when it's embedded in a navigation controller, but that doesn't seem to be the case.
Here's what I have so far:
init(in viewController: UIViewController) {
super.init(frame: CGRect(x: 0, y: 0,
width: viewController.view.frame.size.width, height: 50))
initializeSubviews()
viewController.view.addSubview(self)
self.topAnchor.constraint(equalTo: viewController.topLayoutGuide.bottomAnchor, constant: 0).isActive = true
self.leadingAnchor.constraint(equalTo: viewController.view.leadingAnchor, constant: 0).isActive = true
viewController.view.trailingAnchor.constraint(equalTo: self.trailingAnchor, constant: 0).isActive = true
self.addConstraint(NSLayoutConstraint(item: self, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1, constant: 50))
self.setNeedsLayout()
}
I can achieve this in the interface builder using a placeholder view, so I tried to use the same constraint anchors as the ones used here:
The problem is that the view is always at Y position 0 and is behind the navigation bar. I cannot change the translucency setting of the navigation bar.
I get the following errors in the console when the view is loaded:
<MyApp.MyReusableView: 0x101f3b590; frame = (0 0; 0 0); layer = <CALayer: 0x17003e720>>
2017-01-09 17:07:21.347965 MyApp[2483:984880] [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:0x1742862c0 h=--& v=--& MyApp.MyReusableView:0x101f3b590.width == 0 (active)>",
"<NSLayoutConstraint:0x1702882f0 H:|-(0)-[MyApp.MyReusableView:0x101f3b590] (active, names: '|':UIView:0x101f29f00 )>",
"<NSLayoutConstraint:0x170288340 H:[MyApp.MyReusableView:0x101f3b590]-(0)-| (active, names: '|':UIView:0x101f29f00 )>",
"<NSLayoutConstraint:0x174286450 'UIView-Encapsulated-Layout-Width' UIView:0x101f29f00.width == 375 (active)>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x170288340 H:[MyApp.MyReusableView:0x101f3b590]-(0)-| (active, names: '|':UIView:0x101f29f00 )>
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.
2017-01-09 17:07:21.350923 MyApp[2483:984880] [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:0x174280a50 h=-&- v=-&- UIView:0x102b38f70.width == MyApp.MyReusableView:0x101f3b590.width (active)>",
"<NSAutoresizingMaskLayoutConstraint:0x1742862c0 h=--& v=--& MyApp.MyReusableView:0x101f3b590.width == 0 (active)>",
"<NSLayoutConstraint:0x174286090 H:|-(16)-[UILabel:0x102b23d20'\Uf170'] (active, names: '|':UIControl:0x102b22d10 )>",
"<NSLayoutConstraint:0x174285ff0 H:[UILabel:0x102b23d20'\Uf170']-(8)-[UILabel:0x102b2efa0'Test Notification'] (active)>",
"<NSLayoutConstraint:0x174285f50 H:[UILabel:0x102b2efa0'Test Notification']-(0)-| (active, names: '|':UIControl:0x102b22d10 )>",
"<NSLayoutConstraint:0x174285cd0 H:|-(0)-[UIControl:0x102b22d10] (active, names: '|':UIView:0x102b38f70 )>",
"<NSLayoutConstraint:0x174285870 H:[UIButton:0x102b0d040'\Uf05e']-(0)-| (active, names: '|':UIView:0x102b38f70 )>",
"<NSLayoutConstraint:0x1742857d0 H:[UIControl:0x102b22d10]-(0)-[UIButton:0x102b0d040'\Uf05e'] (active)>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x174285ff0 H:[UILabel:0x102b23d20'']-(8)-[UILabel:0x102b2efa0'Test Notification'] (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.
2017-01-09 17:07:21.352456 MyApp[2483:984880] [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:0x174286360 h=--& v=--& MyApp.MyReusableView:0x101f3b590.height == 0 (active)>",
"<NSLayoutConstraint:0x170288390 MyApp.MyReusableView:0x101f3b590.height == 50 (active)>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x170288390 MyApp.MyReusableView:0x101f3b590.height == 50 (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.
2017-01-09 17:07:21.354622 MyApp[2483:984880] [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)
(
"<_UILayoutSupportConstraint:0x1702877b0 _UILayoutGuide:0x101f3ae30.height == 64 (active)>",
"<_UILayoutSupportConstraint:0x17009d420 V:|-(0)-[_UILayoutGuide:0x101f3ae30] (active, names: '|':UIView:0x101f29f00 )>",
"<NSAutoresizingMaskLayoutConstraint:0x174286270 h=--& v=--& MyApp.MyReusableView:0x101f3b590.midY == 0 (active)>",
"<NSAutoresizingMaskLayoutConstraint:0x174286360 h=--& v=--& MyApp.MyReusableView:0x101f3b590.height == 0 (active)>",
"<NSLayoutConstraint:0x170287f30 V:[_UILayoutGuide:0x101f3ae30]-(0)-[MyApp.MyReusableView:0x101f3b590] (active)>",
"<NSAutoresizingMaskLayoutConstraint:0x174286540 h=-&- v=-&- 'UIView-Encapsulated-Layout-Top' UIView:0x101f29f00.minY == 0 (active, names: '|':UIViewControllerWrapperView:0x102b09100 )>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x170287f30 V:[_UILayoutGuide:0x101f3ae30]-(0)-[MyApp.MyReusableView:0x101f3b590] (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.
2017-01-09 17:07:21.356571 MyApp[2483:984880] [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:0x174280a50 h=-&- v=-&- UIView:0x102b38f70.width == MyApp.MyReusableView:0x101f3b590.width (active)>",
"<NSAutoresizingMaskLayoutConstraint:0x1742862c0 h=--& v=--& MyApp.MyReusableView:0x101f3b590.width == 0 (active)>",
"<NSLayoutConstraint:0x174285f00 UIButton:0x102b0d040'\Uf05e'.width == 50 (active)>",
"<NSLayoutConstraint:0x174285cd0 H:|-(0)-[UIControl:0x102b22d10] (active, names: '|':UIView:0x102b38f70 )>",
"<NSLayoutConstraint:0x174285870 H:[UIButton:0x102b0d040'\Uf05e']-(0)-| (active, names: '|':UIView:0x102b38f70 )>",
"<NSLayoutConstraint:0x1742857d0 H:[UIControl:0x102b22d10]-(0)-[UIButton:0x102b0d040'\Uf05e'] (active)>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x174285f00 UIButton:0x102b0d040''.width == 50 (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.
What am I doing wrong with this view constraint?
make sure that you have set translatesAutoresizingMaskIntoConstraints to false for the view and viewController.view

find a bug when try to add another UIImageView on top of the first one

I'm trying to cross-fade images when the user choose a new image filter.
So I created the secondImageView on top of the first one,and animate the alpha of the top view to show or hide the bottom view.
here is my showSecondImageView() function:
func showSecondImageView() {
view.addSubview(secondImageView)
secondImageView.translatesAutoresizingMaskIntoConstraints = false
let bottomConstraint = secondImageView.topAnchor.constraintEqualToAnchor(imageView.topAnchor)
let leftConstraint = secondImageView.leftAnchor.constraintEqualToAnchor(imageView.leftAnchor)
let rightConstraint = secondImageView.rightAnchor.constraintEqualToAnchor(imageView.rightAnchor)
let heightConstraint = secondImageView.heightAnchor.constraintEqualToAnchor(imageView.heightAnchor)
NSLayoutConstraint.activateConstraints([bottomConstraint,leftConstraint,rightConstraint,heightConstraint])
view.layoutIfNeeded()
self.secondImageView.alpha = 0
UIView.animateWithDuration(0.4) {
self.secondImageView.alpha = 1.0
}
}
the Output:
2016-02-14 23:50:17.444 Filterer[3484:344297] 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:0x7fdf58c33c80 UIImageView:0x7fdf58c30ed0.leading == UIView:0x7fdf58c22480.leading>",
"<NSLayoutConstraint:0x7fdf58c0ff70 UIImageView:0x7fdf58c30ed0.trailing == UIView:0x7fdf58c22480.trailing>",
"<NSLayoutConstraint:0x7fdf58c1d7d0 H:|-(0)-[UIView:0x7fdf58c22480] (Names: '|':UIView:0x7fdf58c19270 )>",
"<NSLayoutConstraint:0x7fdf58c1d820 H:[UIView:0x7fdf58c22480]-(0)-| (Names: '|':UIView:0x7fdf58c19270 )>",
"<NSLayoutConstraint:0x7fdf58f30850 H:[UIImageView:0x7fdf58f30440(600)]>",
"<NSLayoutConstraint:0x7fdf58c5e350 UIImageView:0x7fdf58f30440.left == UIImageView:0x7fdf58c30ed0.left>",
"<NSLayoutConstraint:0x7fdf58c79c40 UIImageView:0x7fdf58f30440.right == UIImageView:0x7fdf58c30ed0.right>",
"<NSLayoutConstraint:0x7fdf58c32190 'UIView-Encapsulated-Layout-Width' H:[UIView:0x7fdf58c19270(375)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x7fdf58f30850 H:[UIImageView:0x7fdf58f30440(600)]>
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.
2016-02-14 23:50:17.446 Filterer[3484:344297] 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.
(
"<_UILayoutSupportConstraint:0x7fdf58c165e0 V:[_UILayoutGuide:0x7fdf58c0fde0(0)]>",
"<_UILayoutSupportConstraint:0x7fdf58c2eb70 _UILayoutGuide:0x7fdf58c0fde0.bottom == UIView:0x7fdf58c19270.bottom>",
"<NSLayoutConstraint:0x7fdf58c35fc0 V:[UIButton:0x7fdf58c35d20'New Photo'(45)]>",
"<NSLayoutConstraint:0x7fdf58c31740 V:[UIStackView:0x7fdf58c30420]-(0)-| (Names: '|':UIView:0x7fdf58c22480 )>",
"<NSLayoutConstraint:0x7fdf58c318a0 V:|-(0)-[UIStackView:0x7fdf58c30420] (Names: '|':UIView:0x7fdf58c22480 )>",
"<NSLayoutConstraint:0x7fdf58c0ffc0 V:|-(0)-[UIImageView:0x7fdf58c30ed0] (Names: '|':UIView:0x7fdf58c19270 )>",
"<NSLayoutConstraint:0x7fdf58c26f70 V:[UIImageView:0x7fdf58c30ed0]-(0)-[UIView:0x7fdf58c22480]>",
"<NSLayoutConstraint:0x7fdf58c26fc0 V:[UIView:0x7fdf58c22480]-(0)-[_UILayoutGuide:0x7fdf58c0fde0]>",
"<NSLayoutConstraint:0x7fdf58f30ab0 V:[UIImageView:0x7fdf58f30440(555)]>",
"<NSLayoutConstraint:0x7fdf58c74640 UIImageView:0x7fdf58f30440.height == UIImageView:0x7fdf58c30ed0.height>",
"<NSLayoutConstraint:0x7fdf58c323e0 'UISV-canvas-connection' UIStackView:0x7fdf58c30420.top == UIButton:0x7fdf58c35d20'New Photo'.top>",
"<NSLayoutConstraint:0x7fdf58c3dd40 'UISV-canvas-connection' V:[UIButton:0x7fdf58c35d20'New Photo']-(0)-| (Names: '|':UIStackView:0x7fdf58c30420 )>",
"<NSLayoutConstraint:0x7fdf58c3fe60 'UIView-Encapsulated-Layout-Height' V:[UIView:0x7fdf58c19270(667)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x7fdf58c35fc0 V:[UIButton:0x7fdf58c35d20'New Photo'(45)]>
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.
2016-02-14 23:50:17.461 Filterer[3484:344297] 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.
(
"<_UILayoutSupportConstraint:0x7fdf58c165e0 V:[_UILayoutGuide:0x7fdf58c0fde0(0)]>",
"<_UILayoutSupportConstraint:0x7fdf58c2eb70 _UILayoutGuide:0x7fdf58c0fde0.bottom == UIView:0x7fdf58c19270.bottom>",
"<NSLayoutConstraint:0x7fdf58c17050 V:[UIButton:0x7fdf58c16940'Edit'(45)]>",
"<NSLayoutConstraint:0x7fdf58c31740 V:[UIStackView:0x7fdf58c30420]-(0)-| (Names: '|':UIView:0x7fdf58c22480 )>",
"<NSLayoutConstraint:0x7fdf58c318a0 V:|-(0)-[UIStackView:0x7fdf58c30420] (Names: '|':UIView:0x7fdf58c22480 )>",
"<NSLayoutConstraint:0x7fdf58c0ffc0 V:|-(0)-[UIImageView:0x7fdf58c30ed0] (Names: '|':UIView:0x7fdf58c19270 )>",
"<NSLayoutConstraint:0x7fdf58c26f70 V:[UIImageView:0x7fdf58c30ed0]-(0)-[UIView:0x7fdf58c22480]>",
"<NSLayoutConstraint:0x7fdf58c26fc0 V:[UIView:0x7fdf58c22480]-(0)-[_UILayoutGuide:0x7fdf58c0fde0]>",
"<NSLayoutConstraint:0x7fdf58f30ab0 V:[UIImageView:0x7fdf58f30440(555)]>",
"<NSLayoutConstraint:0x7fdf58c74640 UIImageView:0x7fdf58f30440.height == UIImageView:0x7fdf58c30ed0.height>",
"<NSLayoutConstraint:0x7fdf58c3fa40 'UISV-alignment' UIButton:0x7fdf58c35d20'New Photo'.bottom == UIButton:0x7fdf58c16940'Edit'.bottom>",
"<NSLayoutConstraint:0x7fdf58c404d0 'UISV-alignment' UIButton:0x7fdf58c35d20'New Photo'.top == UIButton:0x7fdf58c16940'Edit'.top>",
"<NSLayoutConstraint:0x7fdf58c323e0 'UISV-canvas-connection' UIStackView:0x7fdf58c30420.top == UIButton:0x7fdf58c35d20'New Photo'.top>",
"<NSLayoutConstraint:0x7fdf58c3dd40 'UISV-canvas-connection' V:[UIButton:0x7fdf58c35d20'New Photo']-(0)-| (Names: '|':UIStackView:0x7fdf58c30420 )>",
"<NSLayoutConstraint:0x7fdf58c3fe60 'UIView-Encapsulated-Layout-Height' V:[UIView:0x7fdf58c19270(667)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x7fdf58c17050 V:[UIButton:0x7fdf58c16940'Edit'(45)]>
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.
the first picture is the bug one,the second picture is what I want it look like,how to fix it ?
For exactly the same problem you have! I went with the UIView.transitionWithView option mentioned above:
UIView.transitionWithView( myImageView,
duration: 0.4,
options: UIViewAnimationOptions.TransitionCrossDissolve,
animations: { self.myImageView.image = toShow},
completion: { completed in
//do nothing here})
Where the variable "toShow" is the new image. This avoids the need to manage the subview.

Resources