这个问题我已经遇到过很多次了,就是找不到解决办法。
我们的大多数应用程序只在横向模式下运行,我现在正在开发的应用程序(以及我过去开发的许多应用程序)显示以下行为-首次启动时,应用程序在横向模式下正常显示,但屏幕右侧的任何按钮都无法按下。这款应用的表现就好像它只识别屏幕上在纵向模式下可见的部分的触摸,而忽略屏幕右侧的任何触摸。如果我点击另一个viewController,然后回到有问题的viewController,它对屏幕上的所有触摸做出正确的反应。只有在第一次启动时,应用程序才会认为它是在纵向运行,并且无法识别768x1024区域右侧的触摸(或1536x2048或320x480或640x960)
所以我看到一个1024x768的视觉区域,但只能点击屏幕前768像素的按钮(最右边的256像素是不可访问的)
我尝试过的一个解决方案(有限的成功-它以前工作过,但并不总是工作,现在也不工作)已经在多个地方包括这些行,如AppDelegate。m,在rootViewController中。m,并在特定的viewController中。出现上述问题的M:
self.view.frame = CGRectMake(0.0, 0.0, 1024.0, 768.0);
//I've also tried:
CGRect landFrame = self.view.frame;
landFrame.size.width = self.view.frame.size.height;
landFrame.size.height = self.view.frame.size.width;
self.view.frame = landFrame;
任何想法?
.plist值包括:
初始界面方向-横向(右home键)
支持界面方向:
- 项目0 -横向(右home键)
- 项目1 -横向(左home键)
我有这个代码在rootViewController和特定的viewController:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (UIInterfaceOrientationIsLandscape(interfaceOrientation));
//I've also tried:
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
这是我发现的最有用的东西:
In app delegate didFinishLaunchingWithOptions:
Change [window addSubview:navigationController.view];
To [window setRootViewController:navigationController];
,在根视图控制器中,修改
() - BOOL shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation
:
- (BOOL) shouldAutorotate {
返回YES;
}
并在。plist文件