Trick preferredInterfaceOrientationForPresentation to fire on viewController change

前端 未结 2 1200
天命终不由人
天命终不由人 2021-01-18 04:49

I am using MSNavigationPaneViewController from here and have rotation sort of working. I\'ve overridden the rotation methods in my root UINavigationContro

2条回答
  •  一向
    一向 (楼主)
    2021-01-18 05:34

    You can trick the window into re-valuating its supported interface orientations by resetting its rootViewController.

    UIApplication *app = [UIApplication sharedApplication];
    UIWindow *window = [[app windows] objectAtIndex:0];
    UIViewController *root = window.rootViewController;
    window.rootViewController = nil;
    window.rootViewController = root;
    

    You'd need to make sure that when this code executes, -supportedInterfaceOrientations of the root view controller returns the proper mask (corresponding to how you want to force the orientation).

    Be aware, this hack can cause a quick flash on the screen and glitch any ongoing animations.

提交回复
热议问题