user1120133
user1120133

Reputation: 3234

iPhone App with only portrait mode

How can i make my app to be always in portrait mode only. If i rotate iPhone it should not display app in landscape mode.

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation != UIInterfaceOrientationPortrait);

return YES;
}

After this coding when i rotate iPhone app is displayed in landscape mode. How can i make app to be in portrait mode all the time.

Upvotes: 1

Views: 3194

Answers (3)

karim
karim

Reputation: 15589

Seems for iOS 6 you need to override this method,

-(BOOL)shouldAutorotate {
    return NO;
}

Upvotes: 0

BoltClock
BoltClock

Reputation: 723538

Remove the method — you don't need it. An iPhone app always starts in portrait mode unless you force it to start in landscape mode. If this method is absent, it will stay in portrait mode, as it effectively means "My view won't respond to interface orientation changes."

Incidentally, this method actually starts out commented out in Xcode's view controller templates, which is the same as it not being there at all.

Upvotes: 9

iWizard
iWizard

Reputation: 7104

In xcode click left top on your project name and then right below of "TARGETS" you can set "Supported Device Orientations".

Upvotes: 5

Related Questions