问题描述
我正在尝试自动旋转视图,我在此处解释了同样的问题:
。
I'm trying to autorotate a view and I have the same problem explained here:willRotateToInterfaceOrientation not being called.
即使我实现了 shouldAutorotateToInterfaceOrientation
并且在每个<$中返回YES c $ c> UIViewController 我实现的子类; willRotateToInterfaceOrientation
未被调用。
Even though I implemented shouldAutorotateToInterfaceOrientation
and returned YES, in every UIViewController
subclass I implemented; willRotateToInterfaceOrientation
is not being called.
也许有人可以告诉我我错过了什么。我有以下视图控制器结构(我希望这很清楚..):
Perhaps somebody could tell me what I'm missing. I have the following View Controllers structure (I hope this is clear enough..):
NavigationController (Programatically)
-with root > TabBarController (Programatically)
-with tab item > NavigationController (Programatically)
-with root > UITableViewController (a Subclass)
-pushed to navigator controller > UIViewController (a Subclass).
我希望有人可以帮助我。在此先感谢!
I hope someone can help me. Thanks in advance!
推荐答案
您可以尝试通过rootviewcontroller将控制器(NavigationController)插入窗口。
You can try insert your controller(NavigationController) to window by rootviewcontroller.
如果不适合您,请使用通知UIApplicationWillChangeStatusBarOrientationNotification
if not works for you, use notifications UIApplicationWillChangeStatusBarOrientationNotification
编辑
Works:
// custom controller
TestController *t = [[TestController alloc] init];
// navigaton
UINavigationController *controllerinsertIntoTab = [[UINavigationController alloc] initWithRootViewController:t];
// tab bar
UITabBarController *tabbarController = [[UITabBarController alloc] init];
[tabbarController addChildViewController:controllerinsertIntoTab];
// first navigation
UINavigationController *controller = [[UINavigationController alloc] initWithRootViewController:tabbarController];
[self.window setRootViewController:controller];
特别为你
我希望它有用
这篇关于旋转UIView - 未调用willRotateToInterfaceOrientation的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!