"didRotateFromInterfaceOrientation:"未调用

Nit*_*esh 2 objective-c ipad addsubview uiinterfaceorientation

嗨,我想在主视图的小视图中添加子视图控制器的视图,但是didRotateFromInterfaceOrientation:未调用子控制器,因此我可以对方向的更改进行任何更改

Nic*_*ick 17

只有当你将childViewController添加到parentViewController时,才会调用didRotateFromInterfaceOrientation(在childViewController中):

[parentViewController addChildViewController:childViewController];
Run Code Online (Sandbox Code Playgroud)

请注意,您仍然可以使用属性打开/关闭该行为:

self.automaticallyForwardAppearanceAndRotationMethodsToChildViewControllers

默认设置为YES,因此在您的情况下您不需要触摸它.在iOS 6.0干杯后弃用

  • 现在不推荐使用automaticForwardAppearanceAndRotationMethodsToChildViewControllers.在iOS 7中你必须使用它: - (BOOL)shouldAutomaticallyForwardRotationMethods {return YES; } (2认同)

Car*_*ter 5

您是否有超过1个UIViewController同时在屏幕上主动显示其视图?iOS实际上只需要一次在屏幕上有一个属于UIViewController的视图.如果有多于1个,则只有视图为全屏的UIViewController才会调用其方向更改方法.