David Beck
David Beck

Reputation: 10159

Auto rotate custom drawn view on iPhone

I have a UITableView full of custom draw cells. When the view rotates, it just stretches all my custom drawing. How can I get my views to redraw themselves when the view rotates?

Upvotes: 1

Views: 872

Answers (2)

kennytm
kennytm

Reputation: 523164

Set your views' contentMode to UIViewContentModeRedraw.

Upvotes: 3

David Beck
David Beck

Reputation: 10159

My solution was to override like willAnimateRotationToInterfaceOrientation:duration: so:

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration
{
    [self.tableView reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationFade];
}

Of coarse, this only works in 3.0 and you would need to reload all of your sections if you had more than one.

Upvotes: 0

Related Questions