iPhone Tableview Use Cells in Horizontal Scrolling not Vertical

前端 未结 2 1488
轮回少年
轮回少年 2021-01-31 13:00

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 vertica

相关标签:
2条回答
  • 2021-01-31 13:16

    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;
    }
    
    0 讨论(0)
  • 2021-01-31 13:27

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

    0 讨论(0)
提交回复
热议问题