Reputation: 8168
how to force it show on UIDeviceOrientationPortrait only?
example layer1 display on UIInterfaceOrientationLandscapeLeft
when i pushViewController to layer2 it will auto show on UIInterfaceOrientationLandscapeLeft how can i force it to display UIDeviceOrientationPortrait?
Upvotes: 0
Views: 1534
Reputation: 2208
I've had trouble with this. Setting shouldAutorotateToInterfaceOrientation: makes it so that pushing viewControllers onto a stack will result in their views being oriented properly, but you can't force an orientation to portrait or landscape with an explicit function call.
The best I've seen so far is to handle the animation yourself (with a CATransform and related CoreAnimation calls). It's not pretty.
If someone knows of a way to force the view to rotate (i.e. without pushing/popping view controllers, and without rotating the actual device) then please let me/us know.
Upvotes: 0
Reputation: 39376
Put the following in your layer2 viewController:
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
Upvotes: 1
Reputation: 34945
Simply implement shouldAutorotateToInterfaceOrientation:
in your view controller.
Upvotes: 2