In my tableView, I am using automatic row & section footer height. It looks good on iOS 10, but on iOS 11 the section footer overlaps the cell on landscape.
Is there some new iOS 11 property that I'm not setting that's causing this?
This is what it looks like running on iOS 10:
This is what it looks like running on iOS 11:
I have xib with a tableView constrained to the edges of the view. I'm setting row/footer/header height in IB:
Do you set your custom heights for header and footer?
Your table view delegate should implement this methods:
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
which should return appropriate values.
If you return smaller values then your header and footer views have, then they may overlap.
Related
I have UITableView that contains 4 different types of customized cells in storyboard. Each cell has customized UILabels which get variable amount of text data from backend. I am struggling with making the cells resizing correctly. I would really want to change the height of each cell but I can not use heightForRowAtIndexPath because it is called before cellForRowAtIndexPath, but the height is actually calculated within each customized cell.
I tried writing in each cells' height into an array while the UITableView is loading, then just reloading it all over again once, but no effect. I tried using CGFloat rowHeight = UITableViewAutomaticDimension with no success either. The customized labels in each cell definitely grow with text which I see when I just statically change row height to higher numbers. So, I would need somehow my labels to push on rows to make them grow, not sure.
Different similar posts on stackoverflow that I found did not help.
The issue was that I needed to set up top and bottom constraints to the ContentView and NOT to the cell itself in the storyboard.
Label -> ContentView top and bottom constraints need to be set up. And then UITableViewAutomaticDimension specified in viewDidLoad:
self.tableView.rowHeight = UITableViewAutomaticDimension;
estimatedRowHeight should be set too. For example:
self.tableView.estimatedRowHeight = 76.0f;
First Method called is:
- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath
Second:
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
Then:
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
set a break point in the above methods and test it. So if you want to preset the height use estimatedHeightForRowAtIndexPathmethod.
I'm using Autolayout on iOS 8 and make use of UITableViewRowAnimationAutomatic and all of its magic.
When the Tableview appears the cells have a wrong height and the subviews are distributed over the whole cell with a lot of horizontal space between them. When I scroll down or rotate the device and back alls cells are drawn correctly with the correct size.
Debugger says no error and Autolayout warnings are not present.
These cells are only drawn on iPad and I have specified only for sizeclass (Regular | Regular).
Do you any hints what could be the problem?
There are three things that you need to make sure you are doing...
The AutoLayout Constraints should cover the entire height of the cell. So just by looking at the constraints you should be able to say exactly how tall the cell is.
Implement the estimated height for row method...
- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath
{
// return an actual number here. This is a guess of how tall the cells are
return 100;
}
or
// Thanks #rdelmar :-)
self.tableView.estimatedRowHeight = 100;
Implements height for row...
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
// return auto dimension here
return UITableViewAutomaticDimension;
}
Once you have done all three of these it will work.
See my blog here for more data (note, there has been an update since I wrote the blog which I haven't updated yet).
http://www.oliverfoggin.com/using-a-static-uitableview-as-a-layout-device/
I want my UITableView to always show 4 rows, whether it's on retina 3.5 or 4 - with appropriate re-sizing of fonts and subviews in the cell. The app will always be in portrait orientation.
Is there an "elegant" way to do this in storyboard or through constraints?
Or is the best way to determine all the sizes manually, then alter them programmatically?
Set Auto-resize property of UITableView with flexible height, so that it could change height on devices having different screen sizes. Use heightForRowAtIndexPath like this:
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return self.yourTableView.frame.size.height/4;
}
Now, whatever the height of tableview is, you will get same cell heights for all 4 cells.
Note: For your UITableViewCells set view and elements resize properties like flexible height and flexible positions, so that cells' elements get adjusted according to height changes.
I dont understand your question, but if you want to specify the cell height, you can use a UITableViewDelegate method:
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
I'm trying to put the Flowlayout into TableViewCell content.
Everything works fine, but I want to setup dynamic row height based on FlowLayout height.
Using the next method we can get need size. But when I setting it to value that is not equal "44" - FlowLayout stops to show its content. It works only with 44 px.
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 44.0;
}
;
Changing row height via storyboard produces the same result. So Is it possible to contorl the size of nested FlowLayout?
There is an article on cimgf.com Please see: http://www.cimgf.com/2009/09/23/uitableviewcell-dynamic-height/
In my application I would like to hide the table cells in uitableview , and I don't want to hide the header of the tableview in iPhone. On that table view header I would like to add a button, so if anyone know this how to hide the cells in a tableview without hiding the header in tableview in iphone.
If you want to hide all cells in a section, just set the number of rows in that section to 0!
Use table Dalegate method put height of that row 0.
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath