views:

483

answers:

2

I have a tableview that occupies only the bottom third of my view.

I rotate it 90 degrees using CGAffineTransform and resize it:

[UIView beginAnimations:@"rotate" context:nil];
CGRect oldFrame = self.table.frame;
CGPoint oldCentre = self.table.center;
// Swap the width and height
self.table.frame = CGRectMake(0.0, 0.0, oldFrame.size.height, oldFrame.size.width);
self.table.transform = transform;
self.table.center = oldCentre;
[UIView commitAnimations];
[self.table reloadData];

So it goes from a short and fat portrait view to a tall and skinny landscape view. And back again.

My cell text has centre alignment. Going back from the tall and skinny view to the short and fat view doesn't work. The cells gets resized the first time, but stay resized!

How do you get the cells to resize properly?

+1  A: 

This SHOULD resize it for you, I don't quite think it's what you want though, but maybe it'll get you close

-(CGFloat)tableView:(UITableView *)tableView
   heightForRowAtIndexPath:(NSIndexPath *)indexPath
 {
   return 180; //180=pixel size
 }
Matt S.
+3  A: 

I did some more reading and realised my mistake. Use bounds rather than frame.

CGRect oldBounds = self.table.bounds;

This seems to work well.

Megasaur