How to create a view controller that supports both landscape and portrait, but does not rotate between them (keeps its initial orientation)?

I was on the right track, I guess. I solved this by making initialOrientation a property, then setting it from the calling viewController.

I was on the right track, I guess. I solved this by making initialOrientation a property, then setting it from the calling viewController: OrientationLockedViewController *vc = OrientationLockedViewController alloc init; vc. InitialOrientation = self.

InterfaceOrientation; Now I have, in OrientationLockedViewController - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return (interfaceOrientation == self. InitialOrientation); }.

That's a bit of a weird requirement and not something I think UIKit was designed to handle. I don't think its documented when UIKit will call -shouldAutorotateToInterfaceOrientation or how long it might cache those results so I see two possibilities if this behavior is important. Set the initialOrientiation early, when you init your view controller if not earlier so your -shouldAutorotateToInterfaceOrientation behavior never changes but the app will respect the orientation it started in.

Detect the device orientation before you display this controller's view and apply your view's rotation transformation yourself. Depending on your view controller hierarchy you might need to advertise support for all rotations to allow the device to rotate and then set a transform on your view to always rotate to the same orientation regardless of the device's orientation.

Looks like I'm slow and you went for option #1. That should hopefully work reliably for you as long as you don't need this controller instance to be able to switch its initialOrientation when it is not visible. – Jonah Jan 5 at 2:26 A good point.

Naming the property initialOrientation should make it clear that changing this value (even if the view is off screen) is not supported. – Joshua J. McKinnon Jan 7 at 0:42.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions