Tell me, please, is it possible to block the change of screen orientation (or make only portrait) when creating a UIViewController in the following way:

promowindow = [[UIApplication sharedApplication] keyWindow]; promocont = [[UIViewController alloc] init]; [promowindow setRootViewController:promocont]; 

Access to the settings of the main controller is not.

  • Try this: stackoverflow.com/a/26831726/608343 - Vitali Eller
  • Alas, there is no access to UIViewController.m, AppDelegate.m, etc. They are sewn in the archive of the engine. Hope for any method that can be applied to the newly created controller and thereby set or limit the orientation. - Vit

2 answers 2

You can add this method:

 - (UIInterfaceOrientationMask)supportedInterfaceOrientations { return UIInterfaceOrientationMaskPortrait; } 
  • And if there is no access to UIViewController.m? Is it in the engine archive? Is it possible here and now, when creating a controller, to set its orientation? - Vit
  • NSNumber * value = [NSNumber numberWithInt: UIDeviceOrientationPortrait]; [[UIDevice currentDevice] setValue: value forKey: @ "orientation"]; - Orest Mykha

You can implement method overrides in runtime, that is, override the standard method that makes screen flipping.

You can also make a method in that View Controller and call it in init