Skip to content

Instantly share code, notes, and snippets.

@mundstein
Created December 22, 2011 14:01
Show Gist options
  • Save mundstein/1510394 to your computer and use it in GitHub Desktop.
Save mundstein/1510394 to your computer and use it in GitHub Desktop.
Horizontal Tableview e.g. Image browser with minimal code
// Make a picture browser, just like in the Photo app
// **With only six additional lines of code!**
// in viewDidLoad:
self.tableView.transform = CGAffineTransformMakeRotation(-M_PI/2); // turn the table 90° anti-clockwise
self.tableView.showsVerticalScrollIndicator = NO;
self.tableView.pagingEnabled = YES;
// in cellForRowAtIndexPath:
cell.imageView.transform = CGAffineTransformMakeRotation(M_PI/2); // turn the image back 90° clockwise
// implement heightForRowAtIndexPath:
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return self.tableView.frame.size.width;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment