jireh
jireh

Reputation: 89

How it is possible to make one view controller to be viewed in Portrait view in iPhone

I am developing an app, which display number of books fetched from the server and it help the user to read through the book whenever he wants. In every book i am supposed to add simple games. Here, what i have done is, app to be start in a landscape view and it works fine. But now, i want only the game view controller (not the other VC ) should load in portrait view. I googled it , but can't find the real solution. Any help appreciated. Thanks.

Upvotes: 1

Views: 144

Answers (1)

Alexander
Alexander

Reputation: 8147

By default, the UIViewController class displays views in portrait mode only. To support additional orientations, you must override the shouldAutorotateToInterfaceOrientation: method and return YES for any orientations your subclass supports.

So you just have to override your shouldAutorotateToInterfaceOrientation: function in your view controller to view in portrait:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

Upvotes: 1

Related Questions