【发布时间】:2011-02-21 12:38:01
【问题描述】:
我一直在以纵向模式编写我的通用应用程序, 现在经过大约 15 个 nib 文件,许多 viewCotnrollers, 我想实现 shouldAutorotateToInterfaceOrientation 并在横向模式下设计一些屏幕。
添加:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}
对我所有的 viewControllers,不做这项工作。
在调试期间,我看到此方法被调用,但它不起作用!不在模拟器中,不在设备中,不在 Iphone 中,不在 Ipad 中!
我在论坛中搜索了一些答案,并看到了一些使用建议:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationPortrait ||
interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
interfaceOrientation == UIInterfaceOrientationLandscapeRight ||
interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown );
}
也没有用,
添加:
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
和
[[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications];
分别对我的 viewDidLoad 和 viewDidUnload 也不起作用。
我迷路了..任何帮助都可以!
还有一个信息...我所有的视图都是 UIControl 类型,因为我需要 TuchUpInside 才能工作。
感谢您的帮助。
【问题讨论】:
-
您在哪些设备和/或模拟器版本上看到了这个?您的根导航或标签栏控制器的类型是什么?
-
Xcode 3.2.2, iphone 模拟器 3.1.3, (ipad 3.2) 以及使用设备 3.1.3。我的 mainWindow Nib 文件中有选项卡栏和导航控制器。但我所有的类都是 UIViewController 的子类
标签: iphone xcode ipad uiviewcontroller screen-orientation