【问题标题】:Why supportedInterfaceOrientations is calling multiple times in ios6为什么supportedInterfaceOrientations在ios6中多次调用
【发布时间】:2013-03-28 03:57:10
【问题描述】:

在我的 ios6 应用程序中,supportedInterface 定向方法调用了 2 次。如何防止这种情况以及如何使其在 ios6 中只调用一次。请让我知道解决此问题的方法。提前致谢。

-(BOOL)shouldAutorotate
{
    return YES;
}




- (NSUInteger)supportedInterfaceOrientations
{
    orientationControlString=@"thumbnailNotSelected";
    NSLog(@"appdelegate.previewImageScallingmethodCallControlValue value is %d",appdelegate.previewImageScallingmethodCallControlValue); //Gestures settings
    viewsHiddingGesture=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(operationsOnViews:)];
    viewsHiddingGesture.cancelsTouchesInView=NO;
    [self.view addGestureRecognizer:viewsHiddingGesture];


    launchPopOverGesture=[[UILongPressGestureRecognizer alloc]initWithTarget:self action:@selector(annotationsPopOver:)];
    launchPopOverGesture.minimumPressDuration=0.8;
    launchPopOverGesture.allowableMovement=NO;
    launchPopOverGesture.cancelsTouchesInView=NO;
    [tiledView addGestureRecognizer:launchPopOverGesture];
    addAnnotationsGesture=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(addPinAnnotation:)];
    annotationScroller.contentSize=CGSizeMake(258, 700);

    appdelegate =(AppDelegate *)[[UIApplication sharedApplication]delegate];

    UIInterfaceOrientation statusBarOrientation =[UIApplication sharedApplication].statusBarOrientation;


    NSLog(@"statusBarOrientation in supported interface orientations is %d",statusBarOrientation);

    NSLog(@"PREVIEWIMAGESCALLING VALUE IS %d",appdelegate.previewImageScallingmethodCallControlValue);



    if(statusBarOrientation == UIInterfaceOrientationLandscapeLeft  || statusBarOrientation == UIInterfaceOrientationLandscapeRight)
    {
        // code for landscape orientation
        patternRemovalValue=0;

        [self landscapeOrientation];


        if(appdelegate.previewImageScallingmethodCallControlValue==1)
        {
            [self previewImageScallingInLandscape];
            firstOrientationChange=YES;
            appdelegate.getImagesResponseArrayObjectNumber=0;

        }

        else if(((appdelegate.previewImageScallingmethodCallControlValue%2)==0) && (appdelegate.previewImageScallingmethodCallControlValue > 1))
        {
            [self previewImageScallingInLandscape];
            firstOrientationChange=NO;


        }

        appdelegate.orientationChangesCount++;
        patternRemovalValue++;
        appdelegate.previewImageScallingmethodCallControlValue++;


    }
    else if(statusBarOrientation == UIInterfaceOrientationPortraitUpsideDown || statusBarOrientation == UIInterfaceOrientationPortrait)

    {
        // code for Portrait orientation
        patternRemovalValue=0;

        [self potraitOrientation];


        if(appdelegate.previewImageScallingmethodCallControlValue==1)
        {
            [self previewImageScallingInPotrait];
            firstOrientationChange=YES;
            appdelegate.getImagesResponseArrayObjectNumber=0;


        }

        else if(((appdelegate.previewImageScallingmethodCallControlValue%2)==0) && (appdelegate.previewImageScallingmethodCallControlValue > 1))
        {
            [self previewImageScallingInPotrait];
            firstOrientationChange=NO;

        }


        patternRemovalValue++;
        appdelegate.previewImageScallingmethodCallControlValue++;


    }

return UIInterfaceOrientationMaskAll;
}

【问题讨论】:

  • 是的,但是很长我如何发布请告诉我。我是stackoverflow的新手,所以我不知道程序。
  • 您好,感谢您的回复。但是这里有限制。好的,我会用代码再问一个问题,请回复。太紧急了,请帮帮我。
  • 稍等片刻,编辑您的答案并添加您的代码并发布
  • 您好,这里的字符数有限制,所以...
  • 嗨,我去,但是在提交编辑后的问题时,它显示在这样编辑时发生错误......

标签: iphone uiinterfaceorientation


【解决方案1】:

我不知道为什么会发生这种情况,但根据我的经验,您必须假设 supportedInterfaceOrientations 将被多次调用,并让您的逻辑处理它。您应该将大部分代码从那里移到其他地方,也许是 loadView 或您的 init 函数。标准做法是仅在supportedInterfaceOrientations 中有代码,该代码会立即报告您支持的方向。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-09-08
    • 1970-01-01
    • 2015-01-16
    • 2022-01-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多