0

My project is having an iOS8 compatibility issues in a custom UITableViewCell. I am getting the following error

Assertion failure in -[EditableTextCell _setHostsLayoutEngine:], /SourceCache/UIKit/UIKit-3318.16.25/NSLayoutConstraint_UIKitAdditions.m:2760
2015-02-10 23:23:16.959 App_name[2883:507063] *** Terminating app due to uncaught exception
'NSInternalInconsistencyException', reason: 'Must translate autoresizing mask
into constraints to have _setHostsLayoutEngine:YES.'

I have seen similar questions such as UITableViewCell throwing exception and other questions like UITableview Cell exception - 'Must translate autoresizing mask into constraints to have _setHostsLayoutEngine:YES but none have been helpful. I have removed the constraints and I still get the error.

I am using auto layout. EditableTextCell mentioned in the error above is a custom UITableViewCell with UITextFieldDelegate and I am using it in many xib files. My view hierarchy is as follows:-

  1. View_Portrait

    • Portrait_TopContentView
      • Editable Text Cell -- this is the custom class EditableTextCell
        • Content View
      • Table View Cell
        • Content View
      • Button
    • Portrait_TableContainerView
    • portrait _Tab Bar
      • UITabBarItem1
      • UITabBarItem2
  2. Similar structure for the landscape view.

I would really appreciate any help. Please let me know if I can provide more information.

UPDATE: I have tried some solutions but this is still not working for me. Before I setFrame: for the EditableTextCell I put the following lines of code:

    [self.pSearchEditCell setTranslatesAutoresizingMaskIntoConstraints:YES];
    [self.pSearchEditCell.textField setFrame:textFieldFrame]; 
    [self.pSearchEditCell.textField layoutIfNeeded];

where pSearchEditCell is the custom table cell of UITableViewCelland has the UITextField. But this approach is not working for me.

Community
  • 1
  • 1
Karish
  • 151
  • 2
  • 9
  • Have you used this line translatesAutoresizingMaskIntoConstraints = NO for every UIElement added programmatically in your code. if you haven't try this once. – sateesh Feb 11 '15 at 07:16
  • No I haven't used this line. I will try it out today and let you know if this worked for me. – Karish Feb 11 '15 at 12:25
  • Hi @Karish any solution for this? I keep getting this error but unable to find a good solution for this – Hong Zhou Mar 29 '16 at 18:24
  • Hi @HongZhou, there is no elegant solution to it. The custom table cell has to be part of the story board. – Karish Apr 07 '16 at 22:55

1 Answers1

1

Had this same issue. Eventually I just used the cell in a UitableView it seems iOS8 doesn't like it too much if you use cells outside of UITableView.

Robert J. Clegg
  • 7,231
  • 9
  • 47
  • 99
  • what were the constraints that you set where the constraints the same for the cell and the table. I am not sure how to do it, can you give me more information. Thanks. – Karish Feb 11 '15 at 18:58
  • Sorry I don't understand what you're trying to ask. The constraints for the cell get set in the custom cell class. and the uitableview has its own constraints – Robert J. Clegg Feb 11 '15 at 19:10
  • Not nesting the table cell in my storyboard was my problem when getting this error. – matthias_b_nz Nov 09 '15 at 20:47