Xcode TableView Cell dynamic heights with UITableViewAutoDimension - ios

So, I have an issue that seems to have cropped up after having updated the Xcode program on my Mac. I have a tableView that houses an image and subsequent comments underneath, which are initially offscreen until you scroll down and then they load up. The issue I seem to be having is that the cells wont adjust their heights respectively unless I first scroll down to get them loaded, scroll up and then down again. Only then will the UITableViewAutoDimension seem to take effect.
Any suggestions? My auto-laying is exactly how it should be to accommodate dynamic heights of UILabels.
Let me know if more information is needed.
Cheers in advance.

So after about 10 hours of pulling my hair out and literally debugging to sh*t, I found that I had 'use size classes' selected along with 'use auto constraints' which was completely destroying any chance of the table cells from resizing first time. I switched 'use size classes' off in the interface builder document and it seems to have resolved the issue. All I can say is thank f**k! 👍

Related

Auto-layout features not working in a table view cell in xcode?

I am making a simple app since I'm quite new to xCode. I have a table view which holds cells. I've added constraints that I was hoping would dynamically change the width of the cell depending on the device (iphone vs iPad). However, it doesn't seem to be working.
I believe I've set all the necessary constraints, but I guess I must be missing some.
Here is an image of what I'm working with:
And this is the problem, when I change the size of the device I'm working on, the labels in the cell don't resize themselves.
Here are the constraints I'm currently using:
Any help would be appreciated, thanks.
Most probably you haven't updated the frames after changing the size of the view controller

Set max height of UITableView

on the iPhone 5s it seems as though the last item of a specific list shown using UITableView goes slightly off screen and unable to select. Is their any simple way to prevent the tableview from displaying contents offscreen besides checking overtime data is reloaded and the current height of the view?
EDIT: This is all done programmatically and all other tableviews display correctly on the 5s I have tried fiddling with constraints but could not see a difference.
It sounds like your issue has to do with constraints. I'm not sure whether you're using a storyboard to build the view or not, but probably what you need to do is constrain the table view to the bottom of its superview.

Uitableview showing row behind HeaderView ios

I'm working on UITableView.
In that when there is one row in the tableview at that time I'm getting weird. The first row hides behind headerView of UITableView.
As you can see in below image
This is what happening. I'm using autolayout and having constraint also. I can't understand where exactly the issue is.
It seems that you have transparent headers - in case you have sticky headers, this might give you some problems when scrolling.
Your problem probably lies in the header height - check if the height your tableview returns for the header in the first section has the right height (and not 0 or 1 pixel).
Thanks #ALL For giving your answers to my question.
Actually there was constraint problem. I gave the constraint priority to low. and this causes the issue.
I changed it with Required. and it works now perfectly.
Thanks again.
this might happen if your view's height for header is larger than the headers size.
Or it might happen if your cell is implemented in .xib and the contents are going above the coordinates of the visibility.
If you can post the implementation code and snapshots of your interface it might help us to give you more appropriate answer

UICollectionView resizes cells incorrectly after reloadData

I have a UICollectionView that renders some autosizing cells. When I load the data into the collection view initially, the data is perfectly sized the way it should be.
I have a weird issue where, when I trigger reloadData with a new data set, the auto sizing goes wrong and I end up with incorrectly sized cells.
Images attached.
I have tried invalidating the collectionViewLayout before I call reloadData.
Oddly enough, if I remove data, and trigger a reloadData the cells resize to their correct layout. So I am wondering if this is a view recycling issue?
Thanks in advance.
Below is the layout after the screen was initially loaded for the first time.
Below is the layout after the + opens a modal to add a new post, closes, and refreshes the data - see incorrect sizing of cell "Thanks for all your hard work".
Below is the screen after the screen was reloaded from scratch again.
My answer might be a bit late, but getting the similar behaviour I did manage to solve it.
In my case, the problem was with multiline labels — so changing them to single-line solved the case.
As I didn't need to have multilines — I had no further research on them.
I hope, this answer could be a good starting point to find a fix.

iOS: Tableview with custom cells does not scroll

I'm using a nav bar orchestrated set of tableviewcontrollers to display a hierarchy of data. The bottom level of data is displayed in a custom tableviewcell, which has its content described in a xib, and results in a required cell height larger than the default. I posted another question on how to programmatically extract the resulting cell height, but no usable answers, so I now implement heightForRowAtIndexpath to return a hardcoded value that is the height in the xib attributes panel. But, when the table is displayed with more rows than can fit in the normal display size (480h,320w), the bottom row is chopped off as expected, but I can't scroll it to see the rest of the row. I've searched rather extensively, but nothing has helped. I poked at various attributes (tableview sizes, scrollingEnabled, etc.) but they all seem as expected values (e.g., scrollingEnabled is true). One post suggested that no scrolling would occur unless the contentSize was larger then the frame, so I looked at those values, and it sounds promising, in that my frame size is a typical 460h x 320w, but, my contentSize is 0 x 0! Further searching (e.g., "setting contentSize" or "contentSize is 0") didn't clear anything up. I thought contentSize was computed for free from the table row count and their heights, so how could I be getting 0? Even going back to allowing a default row height by not implementing heightForRowAtIndexpath still resulted in a 0 contentSize. Some searches suggest turning off autoLayout for the custom table cell, but still the same. So, what might be going awry? Thanks for any thoughts or guidance.
Update: Sorry, I confess! I had originally been developing on a mac mini with a regular USB mouse, where scrolling in the simulator was left button down and drag. I recently switched to an iMac with the magic mouse. I'm now so used to just dragging my finger on the mouse to scroll code, web pages, etc., that I didn't think to try clicking and holding the left mouse "button", and then dragging the mouse. When I did, everything worked as expected. I had really thought things were hopeless when any similar variables/values in the app on the mini were equal to those on the iMac, but it was just me getting tricked by fancy technology. Sorry for the distraction.
set your tableView's frame and your cell's frame correct,and implement
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath in your UITableView to give a right height. If that doesn't work try set your tableView.autoresizingMask to UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
which can help you with the size of the tableview
I had a similar problem. My tableView would't scroll when the content exceeded the tableViews frame.
The problem for me was that I had "Use Autolayout" checked but no constrains on the tableView. Adding vertical and horizontal space constrains on the tableView fixed my problem

Resources