mbogh / NibDesignable

Elegant way of enabling IBDesignable on your nib-based views
MIT License
342 stars 74 forks source link

NibDesignableTableViewCell not working with UITableView Auto Cell height #21

Closed joshuabryson closed 8 years ago

joshuabryson commented 8 years ago

It seems that using NibDesignableTableViewCells does not work when using automatic cell height on the tableView. In my project I have a tableviewclass, subclass of NibDesignableTableViewCell, all set up hunky dory. The UI shows up (which is great), but it is squished (not so great). At first I thought this was due to using StackViews, but this was not the case (I have a very simple tableViewCell with just a label inside). I attached an image. The first cell is a nib designable cell (and it is squished, the ones below it ended up having a similar layout until I stopped them being a nib designable. My guess is that the issue comes when adding the view to the content view (lines 101-107) and how automatic heights are calculated. simulator screen shot oct 23 2015 8 47 14 am

farzadshbfn commented 8 years ago

In the nib file, instead of adding a UITableViewCell, you must just add a simple View.

hosven commented 8 years ago

can u provide a demo of NibDesignableTableViewCell, thx

farzadshbfn commented 8 years ago

There's nothing to fix in code, you have to fix it in the Nib file. In normal way to work with UITableViewCells in Nib Files, you're adding a UITableViewCell into the Nib file and then start configuring it. But if you're about to use NibDesignableTableViewCell, Do not add UITableViewCell into the Nib file, add a simple UIView.

hosven commented 8 years ago

i did with uiview, but it did not work. nothing appears in the NibDesignableTableViewCell cell in the storyboard. but NibDesignable uiview works. i dont know whats wrong. MyCellProblem.zip

farzadshbfn commented 8 years ago

This way, it's not gonna show up in the storyboard, but you can still work with it and use UITableViewAutomaticDimension. TestCell.zip

farzadshbfn commented 8 years ago

This problem is solved in Xcode 7.3, Designable Objects will be rendered just fine.

nico75005 commented 7 years ago

I had a problem with an infinite loop while I was using NibDesignableTableViewCell with UITableViewCell in a Xib file. So I removed the UITableViewCell and replaced it with a UIView, setting the File's owner class to my custom class and not casting my UIView as my custom class in the identity inspector.

Now I don't have an infinite loop but I get the following error:

Terminating app due to uncaught exception 'NSUnknownKeyException', reason: 
'[<NSObject 0x618000013e00> setValue:forUndefinedKey:]: this class is not key value 
coding-compliant for the key editButton.'

But the button is well linked to my code and there is only this button in my UIView. Doesn't make sense.

farzadshbfn commented 7 years ago

Maybe There is still a ReferenceOutlet in nib file? probably dangled one. Check "Connections Inspector" as well for both File's Owner and UIView.