uitableview - AutoLayout breaks constraints when layoutIfNeeded() is called -


I have a dynamic height UITaleViewCell in UITableView try to apply I'm using Swift with XCode6.

I have also set outlined his cell as the following, (screenshot due to the NDA on XCode6 is XCode5) I "Word wrap line break property Bodeelabel, and several lines To allow, the line number is set to '0'.

Enter image details here

Now if I just inside cell installation of content tableView (tableView: UITableView?, cellForRowAtIndexPath indexPath: NSIndexPath) method, then I get dynamic height behave properly.

However, as I online following rewards available tutorial, I with tableView add another method to determine cell height of the (Teblwu: UITableView! Height Fauraindappat Index : NSIndexPath!) . In the tutorial, what I was following, he asked me to add cell.layoutIfNeeded () , so I added it too.

  override function tableView (tableView: UITableView!, HeightForRowAtIndexPath indexPath: NSIndexPath) - & gt; CGFloat {var cell = tableView! Do as .dequeueReusableCellWithIdentifier (kCellIdentifier) ​​GroupFeedCell // cell configured, frc = self.fetchedResultsController {to feed = frc.objectAtIndexPath (indexPath) as GroupFeed cell.titleLabel.text = feed.name If the message = feed.message {cell.bodyLabel.text = message}} // layout cell cell.layoutIfNeeded () height var height gain //: CGFloat = cell.contentView.systemLayoutSizeFittingSize (UILayoutFittingCompressedSize) .height return height}  < / Pre> 

However, when I ran the program, although the table view still exhibits the dynamic heights of the cells If errors were displayed, then:

  2014-07-27 13: 59: 22.599 FB Group [4631: 9 424] Unable to meet the obstacles together : At least one obstacle in the following list is one that you do not want. Try it: (1) Look at each obstacle and try to figure out what you do not expect; (2) Get the code that connects unwanted obstacles or obstacles and can fix it. (Note: If you're seeing does not come in NSAutoresizingMaskLayoutConstraints that you understand, UIView documentation for property translatesAutoresizingMaskIntoConstraints) ( "& LT; NSLayoutConstraint: 0x17809e780 H: [UILabel: 0x14fd12f50'Body label materials ..."] - (8) - | (name: '|': UITableViewCellContentView: 0x178185d70) & gt; "" & LT; NSLayoutConstraint: 0x17809e7d0 H: | - (8) - [UILabel: 0x14fd12f50'Body label materials ... "] (name : '|' UITableViewCellContentView: 0x178185d70) & gt; Anaslaut Kantentः 0x17809ea50 'UIView- Ankpleted-layout-width "H: [UITableViewCellContentView: 0x178185d70 (0)] & gt;") as to recover from breaking the barrier Will try & lt; NSLayoutConstraint: 0x17809e780H: [Uylabel: 0x14fd12f50 'body label content ...'] - (8) - | (Name: '|': UITableViewCellContentView: 0x178185d70) & gt; To capture it in the debugger, create a symbolic breakpipe on UIViewAlertForUnsatisfiableConstraints. Methods on UIView in the UIConstraintBasedLayoutDebugging category & lt; UIKit / UIViewH & gt; Are listed in Can also be helpful  

I tried to understand what could be wrong, and spend a good time on it, and I thought whenever I read the cell LayoutIfNeeded () remove the method, the odds error disappears.

And it seemed that the obstacles that are conflicting, between the UIView-explained-layout-width I did not add one, and the other from him, all the obstacles to me For the innocent appeared. I tried that UIView-Encapsulated-Layout-Width could cause constraints, but I could not get a satisfactory explanation in my situation. I want to know what will be the cause of this error message and how to solve this problem.

In addition, anyone can tell that what would be the purpose of calling cell.layoutIfNeeded () method inside the calculation of the height of the cell, and when will it be necessary? Most of the tutorials that were covering dynamic height UITableViewCell is Using this method, however, is my program cells still display correctly without the method call, and whenever I think Tried to use the method, it is due to the exception.

/ P>


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -