A transparent Viewcontroller over another Viewcontroller with a different orientation

For an application designed for both iOS 7 and iOS 8, I use two ViewControllers, which should have the following characteristics:

  • ViewController 1 (VC1) is in portrait mode
  • VC1 created ViewController 2 (VC2), which is in landscape mode
  • VC2 has a translucent background, so that the contents of VC1 are visible

I mentioned IOS 7: The transparent background of the Viewcontroller over another Viewcontroller with a different orientation behavior , but the solution provided does not work. On iOS 8, I can either get landscape orientation or transparency for VC2, but not both

That's what I'm doing:

self.view.backgroundColor = [UIColor clearColor]; UILabel* label = [[UILabel alloc] initWithFrame:self.view.frame]; label.text = @" I'M VC1"; [self.view addSubview:label]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ LandscapeViewController* lvc = [[LandscapeViewController alloc] init]; self.modalPresentationStyle = UIModalPresentationOverCurrentContext; //Uncomment this line for transparency but loses orientation //lvc.modalPresentationStyle = UIModalPresentationOverCurrentContext; [self presentViewController:lvc animated:YES completion:nil]; }); 

Any idea what is wrong and how can I make it work?

+5
source share

Source: https://habr.com/ru/post/1202367/


All Articles