开发者

UITableView orientation

开发者 https://www.devze.com 2022-12-21 12:43 出处:网络
I have a class that inherit from UITableViewController, the only orientation allowed is UIInterfaceOreintati开发者_开发问答onPortrait. In this class I\'m using the delegate method didSelectRowAtIndexP

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消