【问题标题】:Autorotate UINavigationController based Application in IPhoneOS 3.0在 iPhoneOS 3.0 中自动旋转基于 UINavigationController 的应用程序
【发布时间】:2010-04-18 14:24:55
【问题描述】:

我有一个应用程序,其代码如下:

window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; // UIWindow *window;
viewController = [TopicsViewController new]; //TopicsViewController *viewController; //This is a UITableViewController
navigationController = [UINavigationController new]; // UINavigationController *navigationController;
UIImageView *background = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"background.png"]];
[self.navigationController.view addSubview:background];
[self.navigationController.view sendSubviewToBack:background];
[navigationController pushViewController:viewController animated:YES];
[window addSubview:[navigationController view]];
[window makeKeyAndVisible];

基本上我正在使用 UINavigationController,然后推送 UITableViewController 或有时是 UIViewController。 UIViewController 包含 UITextView、UIImage、UIScrollView 等元素。问题是我一直试图让这个应用程序响应 iphone 旋转,例如在横屏模式下,应用程序应该切换到横屏模式,反之亦然,但目前没有任何效果。

【问题讨论】:

    标签: iphone-sdk-3.0 uinavigationcontroller uitableview autorotate


    【解决方案1】:

    您需要在 UIViewController 子类中实现 shouldAutorotateToInterfaceOrientation。这会起作用(大部分时间)。

    【讨论】:

    • 这不是很多代码重复吗?我将不得不在 UITableViewController 子类中实现它,然后是 UIViewController 子类。该死的 iPhone OS 2.x 是简单、快速的代码......
    • 这和你在 2.x 中应该做的完全一样。
    • 在 2.x 中,我只需将 shouldAutorotatae... 添加到应用程序委托并返回 YES,这在此处不起作用...
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-11-01
    • 1970-01-01
    • 2010-11-06
    • 2010-11-03
    • 1970-01-01
    • 2010-11-14
    相关资源
    最近更新 更多