0

これがコードです。ビューを作成し、それをselfに追加します(MKMapViewから継承):

private func setup() {

    coverView = UIView()
    coverView.backgroundColor = UIColor.greenColor()
    coverView.layer.zPosition = 10
    addSubview(coverView)
    addConstraints(NSLayoutConstraint.constraintsWithVisualFormat(
        "H:|[cover]|",
        options: NSLayoutFormatOptions.allZeros,
        metrics: nil,
        views: ["cover": coverView]
        ) as! [NSLayoutConstraint])
    addConstraints(NSLayoutConstraint.constraintsWithVisualFormat(
        "V:|[cover]|",
        options: NSLayoutFormatOptions.allZeros,
        metrics: nil,
        views: ["cover": coverView]
        ) as! [NSLayoutConstraint])
}

そしてそれは言います:

2015-09-07 14:53:59.234 ULine[48467:825531] 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) 
(
    "<NSLayoutConstraint:0x7fdd23320250 H:[UIView:0x7fdd2331f860]-(10)-|   (Names: '|':ULine.ULineMap:0x7fdd20e25bc0 )>",
    "<NSLayoutConstraint:0x7fdd232bb840 H:[ULine.ULineMap:0x7fdd20e25bc0]-(0)-|   (Names: '|':UIView:0x7fdd23320910 )>",
    "<NSLayoutConstraint:0x7fdd232bb890 H:|-(0)-[ULine.ULineMap:0x7fdd20e25bc0]   (Names: '|':UIView:0x7fdd23320910 )>",
    "<NSAutoresizingMaskLayoutConstraint:0x7fdd232c0280 h=--& v=--& UIView:0x7fdd2331f860.midX ==>",
    "<NSAutoresizingMaskLayoutConstraint:0x7fdd232c0af0 h=--& v=--& H:[UIView:0x7fdd2331f860(0)]>",
    "<NSLayoutConstraint:0x7fdd237ee370 'UIView-Encapsulated-Layout-Width' H:[UIView:0x7fdd23320910(375)]>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x7fdd23320250 H:[UIView:0x7fdd2331f860]-(10)-|   (Names: '|':ULine.ULineMap:0x7fdd20e25bc0 )>

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.

奇妙なことに、スーパービューをいっぱいにしたいだけです。ありがとう

4

1 に答える 1

0

coverViewが「TranslatesAutoresizingMaskIntoConstraints」を有効にしたため、投稿後に解決しました。追加するだけcoverView.setTranslatesAutoresizingMaskIntoConstraints(false)で、追加の制約は追加されません。

お役に立てば幸いです。

于 2015-09-07T07:09:21.510 に答える