why do i get “Must translate autoresizing mask into constraints to have _setHostsLayoutEngine:YES” in xcode 6 beta

前端 未结 9 1385
死守一世寂寞
死守一世寂寞 2020-12-01 10:38

I have the following code in a swift UITableViewController, but i get a \"Must translate autoresizing mask into constraints to have _setHostsLayoutEngine:YES exception at th

相关标签:
9条回答
  • 2020-12-01 10:41

    In My case I had copied and pasted the cell, but constraints were missing that resulted in this error. if you are copying the cell into another xib file, ensure constraints are also copied or create them again

    0 讨论(0)
  • 2020-12-01 10:42

    In my case the UITableViewCell parent was the main view instead of the UITableView. In this case you just have to put the cell inside the tableview.

    I think this could be a common issue if you drag the cell into the view without taking care of the correct hierarchy.

    0 讨论(0)
  • 2020-12-01 10:44

    I also ran into this issue and it was due to a UITableViewCell subclass being used in the view hierarchy outside of a UITableView as noted in the other answers. In this case I had limited time, so I couldn't move the functionality present in that subclass into a UIView subclass. The workaround I came up with was to just create a UIView instance in my view hierarchy where the cell was supposed to be and transplant the view hierarchy of the cell instance into it, and remove the cell itself from the displayed view hierarchy. So long as I kept the views I moved wired to the various properties of the cell instance, everything keeps working fine.

    It's a bit hacky, but it will keep things running until the time to refactor is available.

    0 讨论(0)
  • 2020-12-01 10:47

    PEOPLE, THIS IS NOT A BUG. As never said down below:

    "This is NOT bug, you simply cannot use a UIView as cell for table view, you must make sure the top level view in the nib file is a UITableViewCell."

    I have tested it and it works.

    You need to create the Xib file and delete the top-level view that it has. After, you drag and drop a UITableViewCell into the nib. This way, this problem will not happen.

    0 讨论(0)
  • 2020-12-01 10:52

    Not sure how much this helps, but I see the same error if I try to place a cell directly in a UIView rather than in a table. This worked fine with Xcode 5 so I suspect it is a bug with XCode6/ios8. In the mean time, debug into that method and look at your tableView. Make sure it actually has an instance of the cell you are trying to retrieve.

    Update: Filed a bug report with Apple and I can confirm that this is an ios8 issue. Unfortunately it is still there as of beta-5, hopefully they will have it fixed before the final release.

    0 讨论(0)
  • 2020-12-01 10:53

    Unselecting 'use auto layout' option from the .xib's properties resolved my issue. - Posting what I did as this may help others.

    Thank you.

    0 讨论(0)
提交回复
热议问题