I keep getting a whole bunch of constraint warnings but they seem to only happen when transitioning view controller through a tab bar controller.
so when i use this code, i get no errors:
let tbc = self.storyboard!.instantiateViewController(withIdentifier: "myViewController") as! myViewController
self.present(tbc, animated: false, completion: nil)
but when i transition with this code, lots of errors:
let tbc = self.storyboard!.instantiateViewController(withIdentifier: "MyTabController") as! UITabBarController
tbc.selectedIndex = 1
tbc.modalTransitionStyle = .coverVertical
self.present(tbc, animated: true, completion: nil)
This is just a simple of the error printed to console:
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-02-16 19:09:28.038332 ParseStarterProject-Swift[42916:640604] [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:0x60800029e500 h=--& v=--& UIView:0x7fb66b551680.width == 142.8 (active)>",
"<NSAutoresizingMaskLayoutConstraint:0x60800029e4b0 h=--& v=--& UIView:0x7fb66b551680.height == 140 (active)>",
"<NSLayoutConstraint:0x60800029be90 UIImageView:0x7fb66b551820.width == UIImageView:0x7fb66b551820.height (active)>",
"<NSLayoutConstraint:0x60800029ba80 V:[UIImageView:0x7fb66b551820]-(50)-| (active, names: '|':UIView:0x7fb66b551680 )>",
"<NSLayoutConstraint:0x60800029c0c0 V:|-(0)-[UIImageView:0x7fb66b551820] (active, names: '|':UIView:0x7fb66b551680 )>",
"<NSLayoutConstraint:0x60800029c110 H:[UIImageView:0x7fb66b551820]-(15)-| (active, names: '|':UIView:0x7fb66b551680 )>",
"<NSLayoutConstraint:0x60800029c160 H:|-(15)-[UIImageView:0x7fb66b551820] (active, names: '|':UIView:0x7fb66b551680 )>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x60800029be90 UIImageView:0x7fb66b551820.width == UIImageView:0x7fb66b551820.height (active)>
So the only constraint i can think this may be related to is shown in the image below:
I've tried the symbolic breakpoint
UIViewAlertForUnsatisfiableConstraints
with action
expr -l objc++ -O -- [[UIWindow keyWindow] _autolayoutTrace]
and get the following report but it doesn't identify any constraints or UI elements.
•UIWindow:0x7fb66b405490
| UITransitionView:0x7fb66b516fa0
| | UILayoutContainerView:0x7fb66b514e80
| | | UINavigationTransitionView:0x7fb66b613980
| | | | UIViewControllerWrapperView:0x7fb66b40e580
| | UITransitionView:0x7fb66b449f90
| UITransitionView:0x7fb66b45bd90
| | UILayoutContainerView:0x7fb66d831410
| | | UITransitionView:0x7fb66b605eb0
| | | | UIViewControllerWrapperView:0x7fb66b5567a0
| | | | | •UIView:0x7fb66b4300c0
| | | | | | *UICollectionView:0x7fb66b970400
| | | | | | | •ParseStarterProject_Swift.PackCollectionViewCell:0x7fb66d836fb0
| | | | | | | | +UIView:0x7fb66d8371d0
| | | | | | | | | *PFImageView:0x7fb66d837370
| | | | | | | | | *UILabel:0x7fb66d837560'This is a series of breat...'
| | | | | | | •ParseStarterProject_Swift.PackCollectionViewCell:0x7fb66b4651f0
| | | | | | | | +UIView:0x7fb66b465020
| | | | | | | | | *PFImageView:0x7fb66b465410
| | | | | | | | | *UILabel:0x7fb66b465600'Ever had trouble falling ...'
| | | | | | | •ParseStarterProject_Swift.PackCollectionViewCell:0x7fb66b560e60
| | | | | | | | +UIView:0x7fb66b561080
| | | | | | | | | *PFImageView:0x7fb66b561220
| | | | | | | | | *UILabel:0x7fb66b561410'This is a week long intro...'
| | | | | | | UIImageView:0x7fb66b4305c0
| | | | | | *_UILayoutGuide:0x7fb66b430260
| | | | | | *_UILayoutGuide:0x7fb66b430410
| | | UITabBar:0x7fb66b54c280
| | | | _UIBarBackground:0x7fb66d830680
| | | | | UIImageView:0x7fb66d830b20
| | | | | UIVisualEffectView:0x7fb66d830d00
| | | | | | _UIVisualEffectBackdropView:0x7fb66d8310a0
| | | | | | _UIVisualEffectFilterView:0x7fb66b40ddd0
| | | | | | _UIVisualEffectFilterView:0x7fb66b556940
| | | | UITabBarButton:0x7fb66d82f890
| | | | | UITabBarSwappableImageView:0x7fb66b43c280
| | | | | UITabBarButtonLabel:0x7fb66d82fb30'Menu'
| | | | UITabBarButton:0x7fb66b63e100
| | | | | UITabBarButtonLabel:0x7fb66b63e3a0
| | | | UITabBarButton:0x7fb66d830120
| | | | | UITabBarSwappableImageView:0x7fb66d828260
| | | | | UITabBarButtonLabel:0x7fb66d8303c0'Path'
| | | UIButton:0x7fb66b63e820
| | | | UIImageView:0x7fb66b4513c0
Legend:
* - is laid out with auto layout
+ - is laid out manually, but is represented in the layout engine because translatesAutoresizingMaskIntoConstraints = YES
• - layout engine host
(lldb)
How can i resolve this or at least how do i specifically find which instances are being reported???? It doesn't seem to effect anything and I've tested it on multiple simulator sizes and devices.
Try to resolve it using DEBUG VIEW HIERARCHY For more detail go through below link - it has the best solution to resolve these type of constraint issue.
Unable to simultaneously satisfy constraints, will attempt to recover by breaking constraint