Created
December 22, 2011 14:01
-
-
Save mundstein/1510394 to your computer and use it in GitHub Desktop.
Horizontal Tableview e.g. Image browser with minimal code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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