简体   繁体   English

UIInterfaceOrientation方法不起作用

[英]UIInterfaceOrientation method not working

Call is not going into the UIInterfaceOrientation delegate method please help 调用未进入UIInterfaceOrientation委托方法,请帮助

here is the code 这是代码

- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
    return YES;
}

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
    if (toInterfaceOrientation == UIInterfaceOrientationPortrait)
    {
        NSLog(@"potrait");
    }
    else
    {

    }
}

Is your view controller inside another view controller? 您的视图控制器是否在另一个视图控制器中?

Look for Technical Q&A QA1688 Why won't my UIViewController rotate with the device? 寻找技术问答QA1688为什么我的UIViewController不随设备旋转? in your developer documentation 在您的开发人员文档中

That will give you a hint of why it isn't working in your case. 这将为您提供提示,说明在您的情况下为什么它不起作用。

I had this problem last week, and here is what I discovered. 上周我遇到了这个问题,这就是我所发现的。 If you are using a tab bar, then you must have 如果使用标签栏,则必须具有

- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
    return YES;
}

in every view controller that is added to the TabBarController in order for any of them to rotate. 在添加到TabBarController的每个视图控制器中以使其旋转。 If you only want certain tabs to rotate, you can still achieve this by adding 如果您只想旋转某些选项卡,则仍然可以通过添加

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
}

There may be a similar resolution if you are using a NavigationController, but I haven't run in to that problem yet. 如果您使用的是NavigationController,可能会有类似的分辨率,但是我还没有遇到这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM