2010-05-06 108 views
7

這不是一個uview的方向問題,我想在縱向或橫向上使用iphone,我想要一個標準tableview(控制器?),它將顯示垂直條帶中的單元格iphone和tableview水平滾動。 - 也就是說一個100%正常桌面視圖,旋轉90度而不旋轉手機方向iPhone Tableview在水平滾動中使用單元格不垂直

這可能嗎?

回答

15

在視圖控制器viewDidLoad中旋轉的tableView:

-(void)viewDidLoad { 
self.table.rowHeight = 320.0; 
self.table.separatorStyle = UITableViewCellSeparatorStyleSingleLine; 
// Rotates the view. 
CGAffineTransform transform = CGAffineTransformMakeRotation(-1.5707963);  
self.table.transform = transform; 
// Repositions and resizes the view. 
CGRect contentRect = CGRectMake(0, 90, 320, 300); 
self.table.frame = contentRect;  
self.table.pagingEnabled 
     = YES; 
[super viewDidLoad]; 
} 

但你將有電池旋轉90度!我解決了旋轉cellView -90°

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
     CGAffineTransform transform = CGAffineTransformMakeRotation(1.5707963); 
     cell.transform = transform; 
} 
+0

嗨nikoz,你知道解決一個問題,在旋轉UITableView這樣的單元格內的模糊內容? – 2011-01-10 20:43:17

+0

可能會更好地使用'M_PI_2'常數,而不是1.5707963。易於閱讀,易於閱讀,不易發生錯別字。 例如:'CGAffineTransformMakeRotation(M_PI_2);' – 2016-03-22 18:57:44