UITableView grouped style cell, header and footer default dimensions - iphone

What are the default cell, section header, and section footer dimensions (width, height, left/right margin, top/bottom margin) for a UITableView in the grouped style?
I already know:
Cell height: 44px, same as always
Section header height: 22px (from this answer) - myTableView.sectionHeaderHeight returns 10, but I can tell that's not right by looking at it when I set section titles.
My reason for asking is that I need to compute the expected total height of a grouped-style UITableView for returning from contentSizeForViewInPopover. But if I'm asking for the heights, I might as well ask for the widths for future reference.

doesn't storyboard tell you the section header's and footer's height? It does tell me based on the screenshot below:
Fig 1: Section header and footer height when Cell set to GROUPED
Fig 2: Section header and footer height when Cell set to PLAIN
The section width depends on your application coding. If you are using the UITableViewController, then the width would be the screen size (depending on iPhone/iPad). If you are having a UITableView within a UIView, then your width would be as you sized it.
Also, the cell height (44) you mentioned is it's default settings. If you are using custom cell, then each cell height could change.
With regard to the cell width, some guy measured it and posted it on his blog. However, if you want to have custom width, then this post on SO will be helpful: How to set the width of a cell in a UITableView in grouped style

Related

Random table view cell height is not working perfectly

I am designing a chat app in which I am using the UITableViewAutomaticDimension property of table view when I am setting the label lines to 6 then all cells height is according to the text which label contains but when I increase the number of lines for label then some cells have extra height. Even when scrolling it then cell height again changed.You can check the image so that you can understand it easily thanks.
You need to give label constraints from top and bottom, rather than center vertically.
Give vertical content hugging priority

Dynamically sizing UITableViewCells

I have worked with dynamically sizing UITableViewCell before. But currently I am facing a problem statement where I am unable to achieve dynamic sizing using autolayout
My cell has three components viz-a-viz one UIImageView, two UILabel
The structure of the cell is as follows
UIImageView has to be of fixed width and height in my case 60X60
UIImageView will be vertically centered inside the UITableViewCell
UIImageView is having a leading constraint of 15 from the UITableViewCell
Now the two UILabels are vertically placed
Both the labels can have dynamic height and I want them to push expand the cell using autolayout but I am only able to achieve keeping the top UILabel of constant height and the below UILabel increases in height.
I want both the UILabel to expand vertically and increase the size of UITableViewCell.
Just use StackView for both label and make both labels numberOfLine to 0 and line break should be WordWrap. give leading,trailing,top and bottom constraints to stack view. for spacing between labels give spacing for stackview on xcode detail pannel.
See the Screenshots for the setting of the constrains.
Add a height constrain to the label with the constant greaterthanEqualTo a fixed value (see screenshot 2). and set the lines to 0. In the table view heightForRowAt indexPath set that to UITableViewAutomaticDimension .

Setting fixed height for all cells at once in iText 2.0.7

Is there anyway where we can set the height of each cell to a particular height? I created multiple cells using PdfPCell,the height is common to all the cells so I wanted to set the height of each cell at once to shorten my code, currently I am doing it using the PdfPCell's setFixedHeight method.
Retrieve the default PdfPCell and set its fixed height. All the cells of the PdfPTable will have the same height afterwards. This will have to be repeated for each table though.

Dynamically set UIScrollView height and UITableView Height depending on content

Setup: I have a scrollview with a label, uiimage, and a tableview (grouped) nested within. The label, uiimage, and tableveiw are populated by a webservice. The last section in the grouped table view contains text that will never be the same and could be as long as 5 characters to 250+. Also, this view is pushed from a basic tableview (so it has a navigation bar. If that matters at all).
Expected: The tableview should extend in height depending on the length of the content received from the web service. Then set the scrollview height to accommodate the height of the tableview
Problem: I'm not quite sure how to approach the issue. I really only know how to change the height to fixed values, which will not work properly in many scenarios.
The width and height of the cell are ignored; the cell cell is re-sized according to the value you return from -tableView:heightForRowAtIndexPath: or (failing that) tableView.rowHeight. It might appear as if the cell is big enough if the label in the cell is sized to be big enough, because the label is allowed to be bigger than (and render outside) the cell.
One way is to override -tableView:heightForRowAtIndexPath: to return the correct height. This isn't really the intended use of UITableView (it's primarily designed for lots of rows of a single height, dynamically generated from a list of content).
Another way is to set tableView.tableFooterView = myCustomFooter instead. This is probably the easiest way. Size it correctly before performing the assignment (the height matters; the table view will set the width for you anyway). Also make sure that the autoresizing flags are not set, or the size will appear to randomly change when the table view changes size (e.g. on autorotation).
I'd just focus on the variable height element, figure out the height that fits the text there. To figure out the height that a string will take when rendered use a snippet like this:
CGFloat MY_TABLECELL_WIDTH = 320;
CGFloat MY_MAX_HEIGHT = 10000;
UIFont *MY_FONT = nil; // load the correct font here.
CGSize maxSize = CGSizeMake(MY_TABLECELL_WIDTH,MY_MAX_HEIGHT);
CGSize textSize = [serverString sizeWithFont:MY_FONT
constrainedToSize:maxSize
lineBreakMode:UILineBreakModeWordWrap];

How do I decrease cell size to 280*35?

I need to decrease the table view cell of navigation controller to 280*35. I have tried to with cgrect, but it's not working...
How can I set it?
The width of a UITableViewCell is always determined by the width of the UITableView that contains it.
You can change the height of your Cell by using UITableViews delegate message tableView:heightForRowAtIndexPath:
You can set row height programmatically, as tonclon pointed out, or, if all rows need to get the same height, set it in Interface Builder as a propery of the UITableView, in de Inspector window under the size tab. It says "height" right at the top, that's the row height.
This is easier and (presumably) faster.