我创建了一个仅在横向模式下工作的应用程序。初始屏幕正常工作,但是在初始屏幕之后,我的第一页未设置为横向模式。我已经附上了屏幕截图,在这里我给出了支持定位方法的代码。我通过打印显示0,0,768,1024的值来检查绑定大小,但是我想要0,0,1024,768。
//checking the frame size
CGRect theRect = self.view.bound;
NSLog(@" frame %f %f %f %f", theRect.origin.x,
theRect.origin.y,
theRect.size.width,
theRect.size.height);
//orientation method
- (BOOL) shouldAutorotate
{
return YES;
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape;
}
-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
UIInterfaceOrientation crntOrntatn = self.interfaceOrientation;
return UIInterfaceOrientationIsLandscape(crntOrntatn) ? crntOrntatn : UIInterfaceOrientationLandscapeLeft;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}
最佳答案
检查应用程序委托。导航控制器已正确初始化?
关于ios - 如何修复ipad中的方向错误?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/19806710/