Autolayout in UITextField: Automatisches Layout nach Ausführung von -layoutSubviews @ weiterhin erforderli

Ich untergeordnete UITextField-Klasse, um eine Beschriftung auf der linken Seite hinzuzufügen. Ich benutze Autolayout, um das Etikett zu gestalten. Ich bekomme jedoch immer diesen Absturz:

So mache ich meinen Layout-Code:

- (void)updateConstraints {

self.segmentLabel.translatesAutoresizingMaskIntoConstraints = NO;

NSLayoutConstraint *constraint;
constraint = [NSLayoutConstraint constraintWithItem:self.segmentLabel attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeHeight multiplier:1.0 constant:0.0f];
[self addConstraint:constraint];
constraint = [NSLayoutConstraint constraintWithItem:self.segmentLabel attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeLeading multiplier:1.0 constant:0.0f];
[self addConstraint:constraint];
constraint = [NSLayoutConstraint constraintWithItem:self.segmentLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeTop multiplier:1.0 constant:0.0f];
[self addConstraint:constraint];
constraint = [NSLayoutConstraint constraintWithItem:self.segmentLabel attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:self.segmentWidth];
[self addConstraint:constraint];

[super updateConstraints];

}

Wenn ich keine Änderungen am Textfeld vornehme, funktioniert das einwandfrei.

Wenn ich jedoch versuche, den Platzhaltertext festzulegen, erhalte ich diese Ausnahme:

Die App wird aufgrund der nicht erfassten Ausnahme "NSInternalInconsistencyException" beendet. Grund: "Automatisches Layout nach Ausführung von" -layoutSubviews "weiterhin erforderlich. DDSegmentedTextFields Implementierung von -layoutSubviews muss super aufrufen. '

Ich überschreibe -layoutSubviews jedoch nicht.

Hat jemand dies angetroffen? Was mache ich falsch

Vielen Dank

Antworten auf die Frage(3)

Ihre Antwort auf die Frage