iPhoneOS 3.0 中基于自动旋转 UINavigationController 的应用程序
我有一个应用程序,其代码如下:
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 旋转,例如,当处于横向状态时,应用程序应该切换到横向,反之亦然,但到目前为止没有任何效果。
I have an application which have code like:
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];
Basically i am using UINavigationController and then push UITableViewController or sometime a UIViewController. UIViewController contain elements such as UITextView, UIImage, UIScrollView. Problem is i have been trying to make this application respond to iphone rotation e.g. when held in landscape, application should switch to landscape and vice versa, but nothing works so far.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要在 UIViewController 子类中实现 shouldAutorotateToInterfaceOrientation。这会起作用(大多数时候)。
You need to implement shouldAutorotateToInterfaceOrientation in your UIViewController subclasses. That will work (most of the time).