我一直在纵向模式下编写我的通用应用程序,现在在完成了大约15个nib文件,许多viewCotnrollers之后,我想实现shouldAutorotateToInterfaceOrientation并在横向模式下设计一些屏幕。
添加:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}
到我所有的viewControllers,都做不到这项工作。
在Debug期间,我看到这个方法被调用了,但是它就是不能工作!不在模拟器中,不在设备中,不在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才能工作。
感谢您的帮助。
发布于 2012-05-15 15:48:15
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
UIInterfaceOrientation des=self.interfaceOrientation;
if(UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPad) //iPad
{
if(des==UIInterfaceOrientationPortrait||des==UIInterfaceOrientationPortraitUpsideDown)//ipad-portairait
{
}
else//ipad -landscape
{
}
}
else//iphone
{
UIInterfaceOrientation des=self.interfaceOrientation;
if(des==UIInterfaceOrientationPortrait||des==UIInterfaceOrientationPortraitUpsideDown) //iphone portrait
{
}
else //iphone -landscape
{
}
}
return YES;
}
发布于 2012-10-18 05:15:31
我遇到了这个问题,但它在iOS6中有效,但在iOS5中不起作用。事实证明,我的故事板中有一个视图,我还没有创建一个视图控制器类。
发布于 2012-11-13 05:17:38
...and最后但并非最不重要的一点是,请确保您尚未激活测试设备上的“纵向锁定”设置(当然不适用于模拟器),这将禁止在任何应用程序中旋转,无论shouldAutorotateToInterfaceOrientation
返回什么。
https://stackoverflow.com/questions/2868132
复制相似问题