1

私の ios6 アプリケーションでは、サポートされているインターフェイス オリエンテーション メソッドが 2 回呼び出されます。これを防ぐ方法と、ios6で1回だけ呼び出すようにする方法。この問題を解決する方法を教えてください。前もって感謝します。

-(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;
}
4

1 に答える 1

0

なぜこれが起こるのかわかりませんが、私の経験では、 supportedInterfaceOrientations が複数回呼び出されると想定し、ロジックでそれを処理する必要があります。ほとんどのコードをそこから移動して、別の場所 (おそらく loadView または init 関数) に移動する必要があります。標準的な方法は、サポートする方向をすぐに報告するコードのみを supportedInterfaceOrientations に含めることです。

于 2013-06-28T14:25:23.343 に答える