I just tried to implement the same thing. I understood from your question that you want to show the VC model in landscape mode. Here is the solution
1) Add a presentation style to your VC model so that it does not appear on the bottom or half-screen. replace the FirstViewController code with the following
-(void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ self.modalViewController = [[ModalViewController alloc] init]; self.modalViewController.modalPresentationStyle = UIModalPresentationFullScreen; NSAssert([NSThread currentThread] == [NSThread mainThread], @"FAIL"); [self presentViewController:self.modalViewController animated:YES completion:^{}]; }); }
2) In the VC model, change the ovveriden method supported by InterfaceOrientations to this
-(UIInterfaceOrientationMask)supportedInterfaceOrientations { return UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight; }
3) To get a clear idea of rotation, add a view to Model VC to make it clear whether the view rotates or not. Add the following code to Model VC
-(void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = [UIColor greenColor]; UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 50, 100)]; view.backgroundColor = [UIColor redColor]; [self.view addSubview:view]; }
Now, having done all this, if you try to open the application, it will only open the model VC in landscape mode, which can be turned either left or right, but in sweat mode, it will be disabled.
source share