Reputation: 340
I have this code (Book1 is a UIViewController Class)
Book1 *book = [self.storyboard instantiateViewControllerWithIdentifier:@"Book1ID"];
[UIView transitionFromView:self.view toView:book.view duration:1 options:UIViewAnimationOptionTransitionCurlDown completion:nil];
The ViewController loads but it the orientation is wrong. It loads in Portrait view but I want it to load in Landscape.
I have the following code in Book1 already but once the view is loaded all autorotation seems to fail.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{
return interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight;}
How can I load this view in Landscape?
Upvotes: 0
Views: 1583
Reputation: 340
I haven't found the problem with my previous methods but I found another way to do it.
This is how:
book = [self.storyboard instantiateViewControllerWithIdentifier:@"Book1ID"];
book.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentViewController:book animated:YES completion:^(void){}];
Special thanks to Aalok Parikh for all your help
Upvotes: 2
Reputation: 5267
So Do the things like the below:
First
Just Select those two orientations as supported device orientations :)
Second
Now Add the key The Last one in image Initial interface orientation
and the value you want either of two landscape values from the list
Third
Now add the below function to all your controller's .m file
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
Forth
Just build and run your project :)
That's it now your application is restricted to the landscape mode only
Happy Codding:)
Upvotes: 0