UITableView orientation
I have a class that inherit from UITableViewController, the only orientation allowed is UIInterfaceOreintati开发者_开发问答onPortrait. In this class I'm using the delegate method didSelectRowAtIndexPath: to push another view in which landscape orientation is allowed. The problem is that when I came back from this view in landscape orientation, the TableView is landscape oriented too. I would like too force the TableView to be in portrait mode, how can I do that ?
Thanks for your help.
As long as your view controller is implementing shouldAutorotateToInterfaceOrientation: to constrain the orientation to portrait, it should "snap back" to portrait mode when you come back.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
If shouldAutorotateToInterfaceOrientation isn't being called, check to see if you have overridden - (id) init.
If you have overridden - (id) init, then you may have forgotten to call super.
Enjoy.
精彩评论