我有一个始终以纵向模式显示的应用程序.
但在某个地方,我有一个必须支持景观的媒体画廊.
默认情况下,项目中支持的方向是纵向.因此,画廊仅以肖像模式显示.
如果我将项目设置更改为以纵向和横向显示,则图库工作正常,但我无法控制其他viewControllers仅以纵向显示.
我尝试了几种方法,如shouldAutoRotate,但没有人工作.
任何ideia怎么解决?
问候
编辑:
解决了 :)
首先,我配置项目以支持所有方向.然后我将此方法添加到AppDelegate.m:
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscape;
}
Run Code Online (Sandbox Code Playgroud)
在此之后,我所做的是阻止每个视图控制器中的方向,减少我想要在横向和纵向中定向的那个.
阻止方向的代码(iOS 7):
- (BOOL)shouldAutorotate
{
return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{
return (UIInterfaceOrientationMaskPortrait);
}
Run Code Online (Sandbox Code Playgroud)
感谢大家回答我:)
ios ×1