我怎样才能让我的应用程序只允许横向但同时(左和右)?因此,如果我旋转 180°,应用程序将旋转,但如果我纵向旋转应用程序不会旋转?
谢谢
我怎样才能让我的应用程序只允许横向但同时(左和右)?因此,如果我旋转 180°,应用程序将旋转,但如果我纵向旋转应用程序不会旋转?
谢谢
尝试将此添加到您的 UIViewController:
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
您可以在此处了解更多信息:UIViewController 类参考