我是ios的新手。
我希望在横向
模式下仅显示一个viewController
,其他所有模式均为纵向。
请帮助我并告诉我如何在应用程序中仅更改一个视图以适用于横向
模式。
我已经搜索过了,但没有找到特定的答案。
我是ios的新手。
我希望在横向
模式下仅显示一个viewController
,其他所有模式均为纵向。
请帮助我并告诉我如何在应用程序中仅更改一个视图以适用于横向
模式。
我已经搜索过了,但没有找到特定的答案。
如果您正在使用导航控制器,并且将此“横向定向”视图控制器推入的控制器仅处于纵向模式,则必须通过CGAffineTransformation手动旋转UI视图。
- (void)viewDidLoad
{
[super viewDidLoad];
// If you require full screen then hide the navigation bar with following commented line.
//[self.navigationController setNavigationBarHidden:YES animated:NO];
// Rotates the view.
CGAffineTransform transform = CGAffineTransformMakeRotation(-M_PI/2);
self.view.transform = transform;
// Repositions and resizes the view.
// If you need NavigationBar on top then set height appropriately
CGRect contentRect = CGRectMake(0, 0, 480, 320);
self.view.bounds = contentRect;
}
ViewController
中。-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape;
}
-(BOOL) shouldAutorotate {
return YES;
}