简体   繁体   中英

iOS View does not change orientation on orientation change

I have a root view which contains a scroll view which contains a (content) view. The content view contains many child controls. Using the simulator, when I change orientation, none of the views, including the scroll view changes orientation. For example the image below starts out in portrait mode and all controls are played out correctly, but moving to landscape mode just shows portrait mode horizontally:

在此处输入图片说明

All of this was laid out using Interface Builder, so I don't have much code in the control view file besides some IB outlets to the controls.

Is there some sort of constraint that is preventing the reorientation of all the controls and views? Or do I always have to lay these out manually on orientation change?

First you need to check you have allowed the app to rotate by checking the orientations you want are ticked:

  • Click on the top-left corner (Show the Project Navigator)
  • Select the name of your project
  • See what is under General->Deployment Info->Device Orientation.
  • Adjust the tickboxes accordingly.

Update:

Also slide up on the simulator and check that rotation isn't locked for the device.

Try putting this in your AppDelegate/view controller:

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

(I don't think it's a constraint/layout issue as the status bar isn't even rotating)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM