Anthology0879
Anthology0879

Reputation: 87

Simulator rotation locked

I just started the tutorial of creating apps in Xcode for iOS 7.0+.

However, when I run the app, and rotate the device in the iOS simulator, the position of the app stays fixed in the portrait mode, while the screen does change to landscape size. This should clearly not happen since it just works in the tutorial.

Can someone help me fix this?

Edit 1: I have ticked all boxed, which did not help. Also I added the code

- (BOOL)shouldAutorotateToInterfaceOrientation:        (UIInterfaceOrientation)interfaceOrientation
{

if ( interfaceOrientation == UIInterfaceOrientationLandscapeLeft  || interfaceOrientation   == UIInterfaceOrientationLandscapeRight || interfaceOrientation ==    UIInterfaceOrientationPortrait)
    return YES; // for supported orientations

return NO;
}

Which did nothing either, I also already noticed that an array of supported interface orientation already exists. Maybe the problem is the iOS Simulator

Edit 2:
Sorry for my stupidity, the rotation lock of iOS was on for some reason... Thanks everyone

Upvotes: 5

Views: 6899

Answers (3)

raurora
raurora

Reputation: 3673

You need to learn about Auto Layout and more specifically how to set constraints.

There is Ray's Video Tutorial on Auto Layout and the Beginning Auto Layout blog post for iOS 7. Maybe you give the rich Apple documentation a chance: Auto Layout Guide

EDIT - Okay, my answer got downvoted. That means the I should give an example - may be duplicate the problem. When I made my first app, I got the same problem. Screenshot below, are you in the same boat?

enter image description here

Upvotes: 0

Fahim Parkar
Fahim Parkar

Reputation: 31647

That is happening because you didn't set landscape orientation for the app.

Xcode default set as Potrait orientation only.

Upvotes: 5

user3206558
user3206558

Reputation: 392

open your project, find your_projetname-info.plist file, add to him new row and write here

Supported interface orientations

this will create in your plist file an array field with supported orientations as elements. add new elements (pressing +) and choise from droplist orientation than you need.

also you can do this in code (your AppDelegate) by adding

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{

if ( interfaceOrientation == <needed_interface_orientation> || interfaceOrientation ==<another_needed_interfaceOrientation>)
        return YES; // for supported orientations

return NO;
}

after this you must read apple autolayout guide (link sugested by

raurora )

Upvotes: 1

Related Questions