Benjamin
Benjamin

Reputation: 663

Present a modal landscape View Controller from a portrait View Controller

I've got a portrait only VC that presents a landscape only VC. I'm struggling to see how it I can make it work. I've had some luck with calling an animation rotating the modal VC after it is presented but that looks a bit dodgy.

I'm stuck with iOS 4.3 so no storyboards.

what I would like is something like...

[landscapeVC setOrentation:UIDeviceOrentaionLanscape];
[portraitVC presentModalViewController:landscapeVC Animated:YES];

Thanks for any help

Upvotes: 2

Views: 1807

Answers (1)

Paresh Navadiya
Paresh Navadiya

Reputation: 38249

Use this in portraitVC's viewDidLoad method and in shouldautorotate method:

 [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:NO];
 [[self view] setBounds:CGRectMake(0, 0, 480, 320)];
 [[self view] setCenter:CGPointMake(160, 240)];
 [[self view] setTransform:CGAffineTransformMakeRotation(M_PI / 2)];

Upvotes: 5

Related Questions