Jack
Jack

Reputation: 3878

Rotate UITableViewCell

I am currently trying to implement a grid view in the iPhone SDK, whereby in portrait mode there are 2 items wide and in landscape mode there are 3. I am implementing this using a UITableView as suggested here.

What is the best way to change the number of rows and the view of the UITableViewCell with device rotation?

If anyone knows a good link to a tutorial about custom UITableViewCell rotation then that would be great.

Cheers

Upvotes: 0

Views: 1190

Answers (1)

Steven Fisher
Steven Fisher

Reputation: 44856

Note: This is an old answer. For iOS 6 and later, you're much better off using UICollectionView.

Original answer:

Start with the basics!

You can detect the orientation change in your view controller using this:

- (void)willRotateToInterfaceOrientation: (UIInterfaceOrientation)toInterfaceOrientation
                                duration: (NSTimeInterval)duration

In that, you can just recalculate how many pictures to show per row and call reloadData on your table. (Your table data source message handlers need to respect the pictures per row, of course.)

Upvotes: 1

Related Questions