我正在尝试使用此代码强制对视图进行定位。
-(BOOL)shouldAutorotate
{
return YES;
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationLandscapeLeft;
}
视图在横向模拟器中加载视图,当我将其转为纵向时,应用程序崩溃,我收到此错误'Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES'
。我想要发生的是,当你把它变成肖像时,它仍然保持在风景中并且不会崩溃。
答案 0 :(得分:6)
如果您尝试在shouldAutorotate中返回NO?
答案 1 :(得分:1)
你试过吗
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape | UIInterfaceOrientationMaskPortrait;
}