2009-09-06 63 views
1

我有一個tableview只佔用了我視圖的底部三分之一。旋轉時調整單元格大小UITableView

我旋轉它使用CGAffineTransform 90度,並調整其大小:

[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]; 

所以它從一個又矮又胖縱向視圖到高又瘦景觀視野去。又回來了。

我的單元格文本有居中對齊。從高而瘦的觀點回到短而胖的觀點是行不通的。細胞第一次調整大小,但保持調整大小!

如何讓細胞正確調整大小?

回答

3

我做了一些更多的閱讀,實現我的錯誤。使用邊界而不是框架。

CGRect oldBounds = self.table.bounds; 

這似乎運作良好。

1

這應該調整它爲你,我不太認爲這是你想要什麼,雖然,但也許它會得到您關閉

-(CGFloat)tableView:(UITableView *)tableView 
    heightForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    return 180; //180=pixel size 
}