UITableViewCell height increases by 2 pixels on every rotation change?

Try saving the itemNameCell 's height to a static CGFloat in your method the first time it's needed, and then just use that from then on. I'd guess it's just some autoresizing in the UI that is stacking up as you rotate.

Up vote 1 down vote favorite 1 share g+ share fb share tw.

I have a UIViewController with a UITableView outlet that I am populating with cells (set up as ivar outlets) that are defined in the same nib file as the table view controller. As I use the rotation feature, the first cell grows by 2 pixels every time that I rotate to a new orientation. Here is the output from the console.

I put a METHOD_LOG call in every method of the class so that I could see if the code was going somewhere unexpected, but it does not seem to be... 2011-06-08 10:10:42.050 MyApp10927:207 METHOD_LOG: viewDidLoad /Users/me/path/to/the/source/code/ItemDetailViewController. M 2011-06-08 10:10:42.054 MyApp10927:207 METHOD_LOG: viewWillAppear: /Users/me/path/to/the/source/code/ItemDetailViewController. M 2011-06-08 10:10:42.054 MyApp10927:207 METHOD_LOG: shouldAutorotateToInterfaceOrientation: /Users/me/path/to/the/source/code/ItemDetailViewController.

M 2011-06-08 10:10:42.056 MyApp10927:207 METHOD_LOG: numberOfSectionsInTableView: /Users/me/path/to/the/source/code/ItemDetailViewController. M 2011-06-08 10:10:42.056 MyApp10927:207 METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController. M 2011-06-08 10:10:42.056 MyApp10927:207 METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.

M 2011-06-08 10:10:42.057 MyApp10927:207 METHOD_LOG: tableView:numberOfRowsInSection: /Users/me/path/to/the/source/code/ItemDetailViewController. M 2011-06-08 10:10:42.057 MyApp10927:207 METHOD_LOG: tableView:heightForRowAtIndexPath: /Users/me/path/to/the/source/code/ItemDetailViewController. M 2011-06-08 10:10:42.0507 MyApp10927:207 METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.

M 2011-06-08 10:10:42.0507 MyApp10927:207 METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController. M 2011-06-08 10:10:42.0509 MyApp10927:207 METHOD_LOG: tableView:numberOfRowsInSection: /Users/me/path/to/the/source/code/ItemDetailViewController. M 2011-06-08 10:10:42.0509 MyApp10927:207 METHOD_LOG: tableView:heightForRowAtIndexPath: /Users/me/path/to/the/source/code/ItemDetailViewController.

M 2011-06-08 10:10:42.0503 MyApp10927:207 item name cell height: 44.000000 2011-06-08 10:10:42.0503 MyApp10927:207 METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController. M 2011-06-08 10:10:42.0503 MyApp10927:207 METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController. M 2011-06-08 10:10:42.061 MyApp10927:207 METHOD_LOG: tableView:numberOfRowsInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.

M 2011-06-08 10:10:42.061 MyApp10927:207 METHOD_LOG: tableView:heightForRowAtIndexPath: /Users/me/path/to/the/source/code/ItemDetailViewController. M 2011-06-08 10:10:42.0508 MyApp10927:207 METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController. M 2011-06-08 10:10:42.0508 MyApp10927:207 METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.

M 2011-06-08 10:10:42.0508 MyApp10927:207 METHOD_LOG: tableView:numberOfRowsInSection: /Users/me/path/to/the/source/code/ItemDetailViewController. M 2011-06-08 10:10:42.063 MyApp10927:207 METHOD_LOG: tableView:heightForRowAtIndexPath: /Users/me/path/to/the/source/code/ItemDetailViewController. M 2011-06-08 10:10:42.063 MyApp10927:207 METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.

M 2011-06-08 10:10:42.064 MyApp10927:207 METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController. M 2011-06-08 10:10:42.064 MyApp10927:207 METHOD_LOG: tableView:numberOfRowsInSection: /Users/me/path/to/the/source/code/ItemDetailViewController. M 2011-06-08 10:10:42.065 MyApp10927:207 METHOD_LOG: tableView:heightForRowAtIndexPath: /Users/me/path/to/the/source/code/ItemDetailViewController.

M 2011-06-08 10:10:42.065 MyApp10927:207 METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController. M 2011-06-08 10:10:42.065 MyApp10927:207 METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController. M 2011-06-08 10:10:42.066 MyApp10927:207 METHOD_LOG: tableView:numberOfRowsInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.

M 2011-06-08 10:10:42.066 MyApp10927:207 METHOD_LOG: tableView:heightForRowAtIndexPath: /Users/me/path/to/the/source/code/ItemDetailViewController. M 2011-06-08 10:10:42.067 MyApp10927:207 METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController. M 2011-06-08 10:10:42.067 MyApp10927:207 METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.

M 2011-06-08 10:10:42.068 MyApp10927:207 METHOD_LOG: tableView:numberOfRowsInSection: /Users/me/path/to/the/source/code/ItemDetailViewController. M 2011-06-08 10:10:42.068 MyApp10927:207 METHOD_LOG: tableView:heightForRowAtIndexPath: /Users/me/path/to/the/source/code/ItemDetailViewController. M 2011-06-08 10:10:42.068 MyApp10927:207 METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.

M 2011-06-08 10:10:42.069 MyApp10927:207 METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController. M 2011-06-08 10:10:42.069 MyApp10927:207 METHOD_LOG: tableView:numberOfRowsInSection: /Users/me/path/to/the/source/code/ItemDetailViewController. M 2011-06-08 10:10:42.070 MyApp10927:207 METHOD_LOG: tableView:heightForRowAtIndexPath: /Users/me/path/to/the/source/code/ItemDetailViewController.

M 2011-06-08 10:10:42.070 MyApp10927:207 METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController. M 2011-06-08 10:10:42.071 MyApp10927:207 METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController. M 2011-06-08 10:10:42.071 MyApp10927:207 METHOD_LOG: tableView:numberOfRowsInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.

M 2011-06-08 10:10:42.071 MyApp10927:207 METHOD_LOG: tableView:heightForRowAtIndexPath: /Users/me/path/to/the/source/code/ItemDetailViewController. M 2011-06-08 10:10:42.072 MyApp10927:207 METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController. M 2011-06-08 10:10:42.072 MyApp10927:207 METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.

M 2011-06-08 10:10:42.073 MyApp10927:207 METHOD_LOG: tableView:numberOfRowsInSection: /Users/me/path/to/the/source/code/ItemDetailViewController. M 2011-06-08 10:10:42.073 MyApp10927:207 METHOD_LOG: tableView:heightForRowAtIndexPath: /Users/me/path/to/the/source/code/ItemDetailViewController. M 2011-06-08 10:10:42.074 MyApp10927:207 METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.

M 2011-06-08 10:10:42.074 MyApp10927:207 METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController. M 2011-06-08 10:10:42.074 MyApp10927:207 METHOD_LOG: tableView:numberOfRowsInSection: /Users/me/path/to/the/source/code/ItemDetailViewController. M 2011-06-08 10:10:42.075 MyApp10927:207 METHOD_LOG: tableView:heightForRowAtIndexPath: /Users/me/path/to/the/source/code/ItemDetailViewController.

M 2011-06-08 10:10:42.075 MyApp10927:207 METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController. M 2011-06-08 10:10:42.076 MyApp10927:207 METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController. M 2011-06-08 10:10:42.076 MyApp10927:207 METHOD_LOG: tableView:numberOfRowsInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.

M 2011-06-08 10:10:42.077 MyApp10927:207 METHOD_LOG: tableView:heightForRowAtIndexPath: /Users/me/path/to/the/source/code/ItemDetailViewController. M 2011-06-08 10:10:42.077 MyApp10927:207 METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController. M 2011-06-08 10:10:42.077 MyApp10927:207 METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.

M 2011-06-08 10:10:42.0508 MyApp10927:207 METHOD_LOG: tableView:numberOfRowsInSection: /Users/me/path/to/the/source/code/ItemDetailViewController. M 2011-06-08 10:10:42.0508 MyApp10927:207 METHOD_LOG: tableView:heightForRowAtIndexPath: /Users/me/path/to/the/source/code/ItemDetailViewController. M 2011-06-08 10:10:42.0568 MyApp10927:207 METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.

M 2011-06-08 10:10:42.0568 MyApp10927:207 METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController. M 2011-06-08 10:10:42.080 MyApp10927:207 METHOD_LOG: tableView:numberOfRowsInSection: /Users/me/path/to/the/source/code/ItemDetailViewController. M 2011-06-08 10:10:42.080 MyApp10927:207 METHOD_LOG: tableView:heightForRowAtIndexPath: /Users/me/path/to/the/source/code/ItemDetailViewController.

M 2011-06-08 10:10:42.080 MyApp10927:207 METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController. M 2011-06-08 10:10:42.081 MyApp10927:207 METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController. M 2011-06-08 10:10:42.081 MyApp10927:207 METHOD_LOG: tableView:numberOfRowsInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.

M 2011-06-08 10:10:42.082 MyApp10927:207 METHOD_LOG: tableView:heightForRowAtIndexPath: /Users/me/path/to/the/source/code/ItemDetailViewController. M 2011-06-08 10:10:42.082 MyApp10927:207 METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController. M 2011-06-08 10:10:42.082 MyApp10927:207 METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.

M 2011-06-08 10:10:42.083 MyApp10927:207 METHOD_LOG: tableView:numberOfRowsInSection: /Users/me/path/to/the/source/code/ItemDetailViewController. M 2011-06-08 10:10:42.083 MyApp10927:207 METHOD_LOG: tableView:heightForRowAtIndexPath: /Users/me/path/to/the/source/code/ItemDetailViewController. M 2011-06-08 10:10:42.084 MyApp10927:207 METHOD_LOG: tableView:cellForRowAtIndexPath: /Users/me/path/to/the/source/code/ItemDetailViewController.

M 2011-06-08 10:10:42.085 MyApp10927:207 METHOD_LOG: tableView:cellForRowAtIndexPath: /Users/me/path/to/the/source/code/ItemDetailViewController. M 2011-06-08 10:10:42.086 MyApp10927:207 METHOD_LOG: tableView:cellForRowAtIndexPath: /Users/me/path/to/the/source/code/ItemDetailViewController. M 2011-06-08 10:10:42.087 MyApp10927:207 METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.

M 2011-06-08 10:10:42.088 MyApp10927:207 METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController. M 2011-06-08 10:10:42.088 MyApp10927:207 METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController. M 2011-06-08 10:10:49.619 MyApp10927:207 METHOD_LOG: shouldAutorotateToInterfaceOrientation: /Users/me/path/to/the/source/code/ItemDetailViewController.

M 2011-06-08 10:10:49.622 MyApp10927:207 METHOD_LOG: numberOfSectionsInTableView: /Users/me/path/to/the/source/code/ItemDetailViewController. M 2011-06-08 10:10:49.623 MyApp10927:207 METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController. M 2011-06-08 10:10:49.623 MyApp10927:207 METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.

M 2011-06-08 10:10:49.624 MyApp10927:207 METHOD_LOG: tableView:numberOfRowsInSection: /Users/me/path/to/the/source/code/ItemDetailViewController. M 2011-06-08 10:10:49.624 MyApp10927:207 METHOD_LOG: tableView:heightForRowAtIndexPath: /Users/me/path/to/the/source/code/ItemDetailViewController. M 2011-06-08 10:10:49.625 MyApp10927:207 METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController.

M 2011-06-08 10:10:49.625 MyApp10927:207 METHOD_LOG: tableView:titleForHeaderInSection: /Users/me/path/to/the/source/code/ItemDetailViewController. M 2011-06-08 10:10:49.625 MyApp10927:207 METHOD_LOG: tableView:numberOfRowsInSection: /Users/me/path/to/the/source/code/ItemDetailViewController. M 2011-06-08 10:10:49.626 MyApp10927:207 METHOD_LOG: tableView:heightForRowAtIndexPath: /Users/me/path/to/the/source/code/ItemDetailViewController.

M 2011-06-08 10:10:49.626 MyApp10927:207 item name cell height: 46.000000 As you can see, after the view loads up, the only methods being called are shouldAutorotateToInterfaceOrientation and the table view delegate methods. The first time you see the cell height it is the default value as defined in Interface Builder, but the second time, it is somehow two pixels bigger. There is no code in any of those methods that is modifying the bounds or frame of any object whatsoever.

Anyone have any ideas of what could be going on or how to diagnose the issue? I thought about setting up a KVO, but I don't think I can get to the frame of the cell with that. EDIT: Here is the code that returns the height for a row at a particular index path: - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { METHOD_LOG; int idx = indexPath section; if (idx == SECTION_ITEM) { NSLog(@"item name cell height: %f", itemNameCell.frame.size.

Height); return itemNameCell.frame.size. Height; } else if (idx == SECTION_DESCRIPTION) { return itemDescriptionCell.frame.size. Height; } ... ... other section identifiers here, you get the idea ... return 44.0; } EDIT 2: Here is the code that creates and returns the cells: - (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)indexPath { METHOD_LOG; UITableViewCell *cell; int idx = indexPath section; if (idx == SECTION_ITEM) { cell = itemNameCell; UILabel *label = (UILabel *)cell viewWithTag:1; label.

Text = jobItem jItemRef blankIfNULL; } else if (idx == SECTION_DESCRIPTION) { cell = itemDescriptionCell; UITextView *textView = (UITextView *)cell viewWithTag:1; textView. Text = jobItem jItemDesc blankIfNULL; } ... ... again, you get the idea ... return cell; } ios uitableview iphone-sdk-4.0 uitableviewcell link|improve this question edited Jun 8 '11 at 17:23 asked Jun 8 '11 at 14:35BP.2,180919 100% accept rate.

Try saving the itemNameCell's height to a static CGFloat in your method the first time it's needed, and then just use that from then on. I'd guess it's just some autoresizing in the UI that is stacking up as you rotate. This assumes you won't want to change the height of the cell programmatically (since you're setting it up in IB).

Yeah, I know I could do that, I was hoping to get to the root of the problem. I am seeing this same problem on another view controller in the same app that is very similar. – BP.

Jun 8 '11 at 19:01 I just hard coded the height values for now, as I have to move on to other issues. If anyone has any ideas in the near future, please post and I will take a look. Thanks.

– BP. Jun 9 '11 at 14:35.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions