पर ऑटोलायआउट के साथ समस्या मुझे xcode 5
प्रोजेक्ट पर ऑटोलायआउट के साथ समस्या हो रही है। मैं एक नेविगेशन नियंत्रक के साथ एक सादा दृश्य नियंत्रक का उपयोग कर रहा हूँ। मेरे पास शीर्ष आधा पर MKMapView
है और नीचे आधा पर UITableView
है। मैं storyboards
का उपयोग कर रहा हूं, और प्रोटोटाइप UITableViewCell
कॉन्फ़िगर किया है, लेकिन मैं कोड के माध्यम से बाधाओं को जोड़ रहा हूं। मैंने प्रोटोटाइप में हर नियंत्रण को दोबारा जांच लिया है और वहां कॉन्फ़िगर की गई कोई बाधा नहीं दिख रही है। मेरी समस्या तब होती है जब मैं UITableViewCell
के लिए बाधाओं को जोड़ता हूं। मेरे पास कक्षों में निम्न कोड है:UITableViewCell
-(void)updateConstraints {
[super updateConstraints];
//first remove old constraints
[self removeConstraints:self.constraints];
[self.nameLabel removeConstraints:self.nameLabel.constraints];
[self.addressLabel removeConstraints:self.nameLabel.constraints];
[self.rentableSquareFeetLabel removeConstraints:self.rentableSquareFeetLabel.constraints];
[self.lastSaleAmountLabel removeConstraints:self.lastSaleAmountLabel.constraints];
[self.lastSaleDateLabel removeConstraints:self.lastSaleAmountLabel.constraints];
[self.thumbnailImageView removeConstraints:self.thumbnailImageView.constraints];
//then set up constraints
NSDictionary *viewsDictionary = NSDictionaryOfVariableBindings(_thumbnailImageView, _nameLabel, _rentableSquareFeetLabel, _lastSaleAmountLabel, _addressLabel, _lastSaleDateLabel);
[self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[_thumbnailImageView(60)]-[_nameLabel(<=200)]-(>=8)-[_rentableSquareFeetLabel]-(>=8)-[_lastSaleAmountLabel]|" options:0 metrics:nil views:viewsDictionary]];
[self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[_nameLabel]-(-4)-[_addressLabel]" options:NSLayoutFormatAlignAllLeading metrics:nil views:viewsDictionary]];
[self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[_lastSaleAmountLabel]-(-4)-[_lastSaleDateLabel]" options:NSLayoutFormatAlignAllLeading metrics:nil views:viewsDictionary]];
}
मुझे डीबगिंग कंसोल में निम्नलिखित मिल रहा है। अपवाद पहली addConstraints लाइन से ट्रिगर किया जाता है। मैं तो बस उन के माध्यम से जारी रखते हैं तो अंत में सब कुछ, पता चलता है के रूप में यह होना चाहिए के रूप में यह लग रहा है xcode तरह सही बाधा को तोड़ने के लिए चुन रहा है:
2013-09-25 15:07:14.169 PECProperties[32381:a0b] 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) (
"<NSIBPrototypingLayoutConstraint:0x9d56c70 'IB auto generated at build time for view with fixed frame' H:|-(0)-[UIImageView:0x9d558f0](LTR) (Names: '|':UITableViewCellContentView:0x9d55620)>",
"<NSIBPrototypingLayoutConstraint:0x9d56d20 'IB auto generated at build time for view with fixed frame' H:[UIImageView:0x9d558f0(60)]>",
"<NSIBPrototypingLayoutConstraint:0x9d56d80 'IB auto generated at build time for view with fixed frame' H:|-(78)-[UILabel:0x9d559e0](LTR) (Names: '|':UITableViewCellContentView:0x9d55620)>",
"<NSLayoutConstraint:0x9d53830 H:[UIImageView:0x9d558f0]-(NSSpace(8))-[UILabel:0x9d559e0]>")
Will attempt to recover by breaking constraint <NSIBPrototypingLayoutConstraint:0x9d56d80 'IB auto generated at build time for view with fixed frame' H:|-(78)-[UILabel:0x9d559e0](LTR) (Names: '|':UITableViewCellContentView:0x9d55620)>
Break on objc_exception_throw to catch this in the debugger. The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
तीसरे NSIBPrototypingLayoutConstraint देखने के किनारे है और एक के बीच 78 अंक से पता चलता लेबल। यही वह जगह है जहां प्रोटोटाइप मोटे तौर पर स्थित है (और यदि मैं इसे प्रोटोटाइप में ले जाता हूं, तो मुझे डिबगिंग कंसोल में बाधा में परिवर्तन दिखाई देता है), लेकिन यह छवि दृश्य और लेबल के बीच "मानक" दूरी की अपनी बाधा के साथ संघर्ष करता है ।
मैंने व्यू कंट्रोलर के cellForRowAtIndexPath
में translatesAutoresizingMaskIntoConstraints=NO
सेट करने का प्रयास किया है, लेकिन ऐसा लगता है कि यह भी मदद नहीं कर रहा है। मैं लेआउट कैसे ठीक कर सकता हूं? यहाँ कवर करने के लिए
मैंने आईओएस 7 में एक-एक-एक बग देखा जो इसी तरह की समस्या का कारण बनता है। मैं आईबी और एक्सकोड में सभी बाधाओं को निर्दिष्ट कर रहा था खुश था। लेकिन अपवाद <सेल ऊंचाई में सभी लंबवत आकारों का योग। समाधान स्वीकार्य था - बिल्ड-टाइम पर बाधाओं में से एक को हटाने के लिए। – Matt