2

xcode でページめくりアプリケーションを作成しようとしています。ページめくりは横向き右では問題なく機能しますが、横向き左ではページめくりが左から発生します。コンテナー ビューを追加すると、横向きの左のページ カールが下から発生し始めましたが、右からではありませんでした。

ここ(http://stackoverflow.com/questions/4780488/i-want-to-use-animation-to-imageview-using-uianimationtransitioncurl-right-or-lef)とここ(http://stackoverflow)でいくつかの提案を見つけました.com/questions/4780488/i-want-to-use-animation-to-imageview-using-uianimationtransitioncurl-right-or-lef)

しかし、これらの両方の提案は、古いスタイルのページ遷移コードであり、ブロック コードではありませんでした。これらを新しいブロック スタイルのコードで変更しようとしましたが、うまくいきません。

ここにコードを添付しています:

- (void)viewDidLoad
{

    UIImage *img = [UIImage imageNamed:@"s1p1.png"];
    currentView.image = img;
    img = [UIImage imageNamed:@"s1p2.png"];
    swapView.image = img;

    UISwipeGestureRecognizer *nextPage;
    nextPage = [[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(turnPage)] autorelease];

    if ([[UIDevice currentDevice] orientation] == UIInterfaceOrientationLandscapeLeft) {
        [nextPage setDirection:UISwipeGestureRecognizerDirectionRight];
    }
    else {
    [nextPage setDirection:UISwipeGestureRecognizerDirectionLeft];
    }

    [self.view addGestureRecognizer:nextPage];

    [super viewDidLoad];
}

-(void) turnPage 
{

    if ([[UIDevice currentDevice] orientation] == UIInterfaceOrientationLandscapeLeft) 
    {
        NSLog(@"landscapeleft");
        mainView.transform = CGAffineTransformMakeRotation(M_PI);
        currentView.transform = CGAffineTransformMakeRotation(-M_PI); 
        swapView.transform = CGAffineTransformMakeRotation(-M_PI); 
        [UIView transitionWithView:mainView
                          duration:1
                           options:UIViewAnimationOptionTransitionCurlUp
                        animations:^{
                            currentView.hidden = YES;
                            swapView.hidden = NO;
                                    }
                        completion:^(BOOL finished){
                            UIImage    *temp = [currentView.image retain];
                            currentView.image = swapView.image;
                            swapView.image = temp;
                            [temp release];
                            currentView.hidden = NO;
                            swapView.hidden = YES;
                        }];

    }
    else
    {
        NSLog(@"landscaperight");
        [UIView transitionWithView:self.view
                          duration:1
                           options:UIViewAnimationOptionTransitionCurlUp
                        animations:^{
                            currentView.hidden = YES;
                            swapView.hidden = NO;
                        }
                        completion:^(BOOL finished){
                            UIImage    *temp = [currentView.image retain];
                            currentView.image = swapView.image;
                            swapView.image = temp;
                            [temp release];
                            currentView.hidden = NO;
                            swapView.hidden = YES;
                        }];

    }


}

ここには 2 つのビューがあります。self.view はウィンドウからのプライマリ ビューで、mainView はコンテナー ビューです。currentView と SwapView はイメージビューです。

これについて何か考えはありますか?これを確認していただきありがとうございます。

4

0 に答える 0