When I load my view controller I'm getting this error:
*** Terminating app due to uncaught exception 'CALayerInvalid', reason: 'layer <CALayer: 0x7fda42c66e30> is a part of cycle in its layer tree'
I don't know why. I think I might've added a third party framework that messed with layers, but I removed it in my troubleshooting. Any insights would be great.
EDIT
It happens during viewDidLoad
of my tableViewcontroller
. I have a tableView on my second vc. I've narrowed it down to it crashing on setting the heightForRowAtIndexPath
on the 4th custom cell. The cell is on a static tableView
................. :/ Getting closer!
Here's my heightForRowAtIndexPath
:
override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
print("idx = \(indexPath.row)")
return super.tableView(tableView, heightForRowAtIndexPath: indexPath)
}
Pretty generic. Any thoughts on where else this might be caused?
This might help someone still in trouble with this, For me the issue was this
Adding a layer to itself
check if you add self.view in self.view, exemple:
or
I had the same error too and found this fix
It mentions to remove the accessoryView Outlet which you will see on the TableView.
To do this:
Can't post the screenshot, because I don't have enough reputation. The blog post shows you how to do it though.
I had this issue too, and found out I accidentally created an outlet from the TableViewCell backgroundView to the TableView's view - DOH!
I solved one crash of this kind by removing the outlet to
File' s owner
in some ofxib
UI files. I answer here in case someone encounters a similar thing.One of my friend was facing the same issue. The root cause was lying in the viewForHeaderInSection delegate of UITableview.
He was adding a label in main view of the controller in this delegate. He was supposed to create a UIView and return it in this delegate but unfortunately he was returning self.view there. So removing this code fixed the issue.