Constraints WARNING

Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen

  • Constraints WARNING

    Moin,

    folgende Constraints setze ich:

    Quellcode

    1. addConstraintsWithFormat(format: "H:|[v0]|", views: thumbnailImageView)
    2. addConstraintsWithFormat(format: "H:|-8-[v0(44)]|", views: userProfileImage)
    3. addConstraintsWithFormat(format: "V:|[v0]-8-[v1(44)]-30-|", views: thumbnailImageView, userProfileImage)
    4. addConstraint(NSLayoutConstraint(item: titleLabel, attribute: .top, relatedBy: .equal, toItem: thumbnailImageView, attribute: .bottom, multiplier: 1, constant: 8))
    5. addConstraint(NSLayoutConstraint(item: titleLabel, attribute: .left, relatedBy: .equal, toItem: userProfileImage, attribute: .right, multiplier: 1, constant: 8))
    6. addConstraint(NSLayoutConstraint(item: titleLabel, attribute: .right, relatedBy: .equal, toItem: thumbnailImageView, attribute: .right, multiplier: 1, constant: 0))
    7. addConstraint(NSLayoutConstraint(item: titleLabel, attribute: .height, relatedBy: .greaterThanOrEqual, toItem: self, attribute: .height, multiplier: 0, constant: 20))
    8. addConstraint(NSLayoutConstraint(item: subTitleLabel, attribute: .top, relatedBy: .equal, toItem: titleLabel, attribute: .bottom, multiplier: 1, constant: 0))
    9. addConstraint(NSLayoutConstraint(item: subTitleLabel, attribute: .left, relatedBy: .equal, toItem: userProfileImage, attribute: .right, multiplier: 1, constant: 8))
    10. addConstraint(NSLayoutConstraint(item: subTitleLabel, attribute: .right, relatedBy: .equal, toItem: thumbnailImageView, attribute: .right, multiplier: 1, constant: 0))
    11. addConstraint(NSLayoutConstraint(item: subTitleLabel, attribute: .height, relatedBy: .equal, toItem: self, attribute: .height, multiplier: 0, constant: 20))
    Alles anzeigen


    Folgende Meldung erhalte ich

    Quellcode

    1. 2018-03-14 12:26:27.823907+0100 NoStoryboard[26816:8211188] [LayoutConstraints] Unable to simultaneously satisfy constraints.
    2. Probably at least one of the constraints in the following list is one you don't want.
    3. Try this:
    4. (1) look at each constraint and try to figure out which you don't expect;
    5. (2) find the code that added the unwanted constraint or constraints and fix it.
    6. (
    7. "<NSLayoutConstraint:0x600000096620 H:[NoStoryboard.CustomImageView:0x7ffe69812040]-(0)-| (active, names: '|':NoStoryboard.EventCell:0x7ffe69811db0 )>",
    8. "<NSLayoutConstraint:0x600000096760 H:[NoStoryboard.CustomImageView:0x7ffe698126c0]-(0)-| (active, names: '|':NoStoryboard.EventCell:0x7ffe69811db0 )>",
    9. "<NSLayoutConstraint:0x600000096990 H:[NoStoryboard.CustomImageView:0x7ffe698126c0]-(8)-[UILabel:0x7ffe69812910'UV vs. Schwarzlicht Party'](LTR) (active)>",
    10. "<NSLayoutConstraint:0x6000000968f0 UILabel:0x7ffe69812910'UV vs. Schwarzlicht Party'.right == NoStoryboard.CustomImageView:0x7ffe69812040.right (active)>"
    11. )
    12. Will attempt to recover by breaking constraint
    13. <NSLayoutConstraint:0x600000096990 H:[NoStoryboard.CustomImageView:0x7ffe698126c0]-(8)-[UILabel:0x7ffe69812910'UV vs. Schwarzlicht Party'](LTR) (active)>
    14. Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
    15. The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
    16. 2018-03-14 12:26:27.824866+0100 NoStoryboard[26816:8211188] [LayoutConstraints] Unable to simultaneously satisfy constraints.
    17. Probably at least one of the constraints in the following list is one you don't want.
    18. Try this:
    19. (1) look at each constraint and try to figure out which you don't expect;
    20. (2) find the code that added the unwanted constraint or constraints and fix it.
    21. (
    22. "<NSLayoutConstraint:0x600000096620 H:[NoStoryboard.CustomImageView:0x7ffe69812040]-(0)-| (active, names: '|':NoStoryboard.EventCell:0x7ffe69811db0 )>",
    23. "<NSLayoutConstraint:0x600000096760 H:[NoStoryboard.CustomImageView:0x7ffe698126c0]-(0)-| (active, names: '|':NoStoryboard.EventCell:0x7ffe69811db0 )>",
    24. "<NSLayoutConstraint:0x600000096a80 H:[NoStoryboard.CustomImageView:0x7ffe698126c0]-(8)-[UILabel:0x7ffe69812bf0'8.804 km \U00b7 Holsteinisches...'](LTR) (active)>",
    25. "<NSLayoutConstraint:0x600000096ad0 UILabel:0x7ffe69812bf0'8.804 km \U00b7 Holsteinisches...'.right == NoStoryboard.CustomImageView:0x7ffe69812040.right (active)>"
    26. )
    27. Will attempt to recover by breaking constraint
    28. <NSLayoutConstraint:0x600000096a80 H:[NoStoryboard.CustomImageView:0x7ffe698126c0]-(8)-[UILabel:0x7ffe69812bf0'8.804 km · Holsteinisches...'](LTR) (active)>
    29. Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
    30. The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
    31. 2018-03-14 12:26:27.826794+0100 NoStoryboard[26816:8211188] [LayoutConstraints] Unable to simultaneously satisfy constraints.
    32. Probably at least one of the constraints in the following list is one you don't want.
    33. Try this:
    34. (1) look at each constraint and try to figure out which you don't expect;
    35. (2) find the code that added the unwanted constraint or constraints and fix it.
    36. (
    37. "<NSLayoutConstraint:0x608000096da0 H:[NoStoryboard.CustomImageView:0x7ffe675144c0]-(0)-| (active, names: '|':NoStoryboard.EventCell:0x7ffe675101f0 )>",
    38. "<NSLayoutConstraint:0x608000096ee0 H:[NoStoryboard.CustomImageView:0x7ffe67514710]-(0)-| (active, names: '|':NoStoryboard.EventCell:0x7ffe675101f0 )>",
    39. "<NSLayoutConstraint:0x608000097110 H:[NoStoryboard.CustomImageView:0x7ffe67514710]-(8)-[UILabel:0x7ffe67514b50'KnallSCHWARZ mit Johann S...'](LTR) (active)>",
    40. "<NSLayoutConstraint:0x608000097070 UILabel:0x7ffe67514b50'KnallSCHWARZ mit Johann S...'.right == NoStoryboard.CustomImageView:0x7ffe675144c0.right (active)>"
    41. )
    42. Will attempt to recover by breaking constraint
    43. <NSLayoutConstraint:0x608000097110 H:[NoStoryboard.CustomImageView:0x7ffe67514710]-(8)-[UILabel:0x7ffe67514b50'KnallSCHWARZ mit Johann S...'](LTR) (active)>
    44. Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
    45. The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
    46. 2018-03-14 12:26:27.827367+0100 NoStoryboard[26816:8211188] [LayoutConstraints] Unable to simultaneously satisfy constraints.
    47. Probably at least one of the constraints in the following list is one you don't want.
    48. Try this:
    49. (1) look at each constraint and try to figure out which you don't expect;
    50. (2) find the code that added the unwanted constraint or constraints and fix it.
    51. (
    52. "<NSLayoutConstraint:0x608000096da0 H:[NoStoryboard.CustomImageView:0x7ffe675144c0]-(0)-| (active, names: '|':NoStoryboard.EventCell:0x7ffe675101f0 )>",
    53. "<NSLayoutConstraint:0x608000096ee0 H:[NoStoryboard.CustomImageView:0x7ffe67514710]-(0)-| (active, names: '|':NoStoryboard.EventCell:0x7ffe675101f0 )>",
    54. "<NSLayoutConstraint:0x608000097200 H:[NoStoryboard.CustomImageView:0x7ffe67514710]-(8)-[UILabel:0x7ffe67514e30'8.814 km \U00b7 DIE VILLA KLUB...'](LTR) (active)>",
    55. "<NSLayoutConstraint:0x608000097250 UILabel:0x7ffe67514e30'8.814 km \U00b7 DIE VILLA KLUB...'.right == NoStoryboard.CustomImageView:0x7ffe675144c0.right (active)>"
    56. )
    57. Will attempt to recover by breaking constraint
    58. <NSLayoutConstraint:0x608000097200 H:[NoStoryboard.CustomImageView:0x7ffe67514710]-(8)-[UILabel:0x7ffe67514e30'8.814 km · DIE VILLA KLUB...'](LTR) (active)>
    59. Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
    60. The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
    61. 2018-03-14 12:26:27.828984+0100 NoStoryboard[26816:8211188] [LayoutConstraints] Unable to simultaneously satisfy constraints.
    62. Probably at least one of the constraints in the following list is one you don't want.
    63. Try this:
    64. (1) look at each constraint and try to figure out which you don't expect;
    65. (2) find the code that added the unwanted constraint or constraints and fix it.
    66. (
    Alles anzeigen


    Ich finde leider meine Fehler nicht. Die App selbst sieht auch gut aus, also scheint es ja irgendwie zu funktionieren. Die Meldungen würde ich aber schon gerne weg haben.

    Hat jemand vielelicht eine Idee??
  • Ach ja hier die Helper Funktion

    Quellcode

    1. extension UIViewController {
    2. func addConstraintsWithFormat(format: String, views: UIView...){
    3. var viewsDictionary = [String: UIView]()
    4. for(index, view) in views.enumerated() {
    5. let key = "v\(index)"
    6. view.translatesAutoresizingMaskIntoConstraints = false
    7. viewsDictionary[key] = view
    8. }
    9. self.view.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: format, options: NSLayoutFormatOptions(), metrics: nil, views: viewsDictionary))
    10. }
    11. }
    Alles anzeigen