我有一个应用程序,总是以纵向模式显示。
但在某些地方,我必须支持横向的媒体库。
项目默认支持的方向为纵向。因此,媒体库只能以纵向模式显示。
如果我将项目设置更改为同时支持纵向和横向,则媒体库可以正常工作,但我不能控制其他视图控制器仅以纵向模式显示。
我尝试了几种方法,如shouldAutoRotate,但没有一种方法起作用。
有什么解决方法吗?
谢谢
编辑:
问题已解决 :)
首先,我配置了项目以支持所有方向。然后我添加了这个方法到AppDelegate.m中:
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscape;
}
接下来我所做的是在每个视图控制器中禁止方向,除了我想要横向和纵向方向的那个。
禁止方向的代码(iOS 7):
- (BOOL)shouldAutorotate
{
return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{
return (UIInterfaceOrientationMaskPortrait);
}
感谢所有回答我的人 :)