如何在iOS5中获得默认的LandscapeLeft方向? [英] How to get default LandscapeLeft Orientation in iOS5?

查看:108
本文介绍了如何在iOS5中获得默认的LandscapeLeft方向?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很抱歉,如果这个问题重复,但我找不到相同的解决方案。
在iOS6中,如果我想为一个UIViewController设置默认方向,我只需使用:

Sorry if this question is duplicate, but I can't find the same solution. In iOS6, if I want to set default orientation for one UIViewController, I just use:

- (BOOL)shouldAutorotate {
    return YES;
}
- (NSUInteger)supportedInterfaceOrientations{
    return UIInterfaceOrientationMaskLandscapeLeft;
}

但是如何在iOS5中做同样的事情,我测试两者:

But how to do same in iOS5, I test both:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
    return (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft);//not default
}
and
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
    return (toInterfaceOrientation == UIInterfaceOrientationMaskLandscapeLeft);// = return NO;
}

但默认方向始终是Portrait.Any建议?

But the default orientation always Portrait.Any suggestion?

推荐答案

调用以下方法,你要检查orientation.happy编码的状态: - )

call the below method where you want to check the status of orientation.happy coding :-)

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
    [self CheckForViewForOrientation:toInterfaceOrientation];
}

- (void) CheckForViewForOrientation:(UIInterfaceOrientation)orientation
{
    if (orientation == UIInterfaceOrientationPortrait || orientation == UIInterfaceOrientationPortraitUpsideDown)
    {
        //Ur lable portrait view
    }
    else if (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight)
    {
        //Ur lable for landscape view
    }
}

这篇关于如何在iOS5中获得默认的LandscapeLeft方向?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆