Guest User

Untitled

a guest
Nov 23rd, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.47 KB | None | 0 0
  1. UIButton *sortButton = [UIButton buttonWithType:UIButtonTypeCustom];
  2. [sortButton setFrame:CGRectMake(10, 0, 100, 30)];
  3. [sortButton setTitle:@"Sort" forState:UIControlStateNormal];
  4. [[sortButton titleLabel] setFont:[UIFont boldSystemFontOfSize:13]];
  5. [sortButton setBackgroundImage:[UIImage imageNamed:@"backgroun-button.png"] forState:UIControlStateNormal];
  6. [sortButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  7. [sortButton addTarget:self action:@selector(sortCollection:) forControlEvents:UIControlEventTouchUpInside];
  8. [sortButton applyNavBarConstraints:100 height:30];
  9.  
  10. [self setSortCollection:item];
  11.  
  12. [self setToolbarItems:[NSArray arrayWithObjects:self.sortCollection, nil]];
  13.  
  14. - (void)applyNavBarConstraints:(CGFloat)width height:(CGFloat)height
  15. {
  16. if (width == 0 || height == 0) {
  17. return;
  18. }
  19.  
  20. NSLayoutConstraint* w = [self.widthAnchor constraintEqualToConstant:width];
  21. NSLayoutConstraint * h = [self.heightAnchor constraintEqualToConstant:height];
  22.  
  23. [w setActive:YES];
  24. [h setActive:YES];
  25. }
  26.  
  27. [LayoutConstraints] Unable to simultaneously satisfy constraints.
  28. Probably at least one of the constraints in the following list is one you don't want.
  29. Try this:
  30. (1) look at each constraint and try to figure out which you don't expect;
  31. (2) find the code that added the unwanted constraint or constraints and fix it.
  32. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)
  33. (
  34. "<NSAutoresizingMaskLayoutConstraint:0x608000280af0 h=--& v=--& UIToolbar:0x7f85ca1327e0.width == 768 (active)>",
  35. "<NSLayoutConstraint:0x6000002826c0 _UIToolbarContentView:0x7f85ca1307b0.trailing == UIToolbar:0x7f85ca1327e0.trailing (active)>",
  36. "<NSLayoutConstraint:0x600000282580 H:|-(0)-[_UIToolbarContentView:0x7f85ca1307b0] (active, names: '|':UIToolbar:0x7f85ca1327e0 )>",
  37. "<NSLayoutConstraint:0x600000285410 H:|-(0)-[_UIButtonBarStackView:0x7f85ca135660] (active, names: '|':_UIToolbarContentView:0x7f85ca1307b0 )>",
  38. "<NSLayoutConstraint:0x600000285460 _UIButtonBarStackView:0x7f85ca135660.trailing == _UIToolbarContentView:0x7f85ca1307b0.trailing (active)>",
  39. "<NSLayoutConstraint:0x600000285500 UIButton:0x7f85ca131b90'Sortieren'.width == 100 (active)>",
  40. "<NSLayoutConstraint:0x608000280ff0 'UISV-canvas-connection' UILayoutGuide:0x6000001ba240'UIViewLayoutMarginsGuide'.leading == UIButton:0x7f85ca131b90'Sortieren'.leading (active)>",
  41. "<NSLayoutConstraint:0x608000280d70 'UISV-canvas-connection' UILayoutGuide:0x6000001ba240'UIViewLayoutMarginsGuide'.trailing == UIButton:0x7f85ca131b90'Sortieren'.trailing (active)>",
  42. "<NSLayoutConstraint:0x600000284f10 'UIView-leftMargin-guide-constraint' H:|-(0)-[UILayoutGuide:0x6000001ba240'UIViewLayoutMarginsGuide'](LTR) (active, names: '|':_UIButtonBarStackView:0x7f85ca135660 )>",
  43. "<NSLayoutConstraint:0x600000285190 'UIView-rightMargin-guide-constraint' H:[UILayoutGuide:0x6000001ba240'UIViewLayoutMarginsGuide']-(0)-|(LTR) (active, names: '|':_UIButtonBarStackView:0x7f85ca135660 )>"
  44. )
  45.  
  46. Will attempt to recover by breaking constraint
  47. <NSLayoutConstraint:0x600000285500 UIButton:0x7f85ca131b90'Sortieren'.width == 100 (active)>
  48.  
  49. Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
  50. The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
Add Comment
Please, Sign In to add comment