7

This is not an uiview orientation question, I want to Have the iphone in Portrait or Landscape, and I want a standard tableview(controller?) that will display cells in a vertical strip down the iphone and the tableview scrolls horizontally. -I.e. a 100% normal tableview, that is rotated 90deg without rotating the phone orientation

Is this possible?

2 Answers 2

17

in the view controller rotate the tableView in viewDidLoad:

-(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]; 
}

but you will have cell rotated 90°!!! I solved rotating cellView -90°

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath 
{
        CGAffineTransform transform = CGAffineTransformMakeRotation(1.5707963);
        cell.transform = transform;
}
2
  • Hi nikoz, do you know to solve a problem with blurred content inside the cells when rotate the UITableView like this? Jan 10, 2011 at 20:43
  • Would probably be better to use the 'M_PI_2' constant, instead of 1.5707963. Easier to read, easier on the eyes, and less prone to typos. eg: CGAffineTransformMakeRotation(M_PI_2); Mar 22, 2016 at 18:57
0

Now anybody looking for simple and better way use UICollectionView with "Horizontal scrolling" enabled.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.