0

電話すると:

[self dismissViewControllerAnimated:Yes.....];

ビューを表示するために使用されたアニメーションとは反対のことを行います。

例:あなたが電話した場合:

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Storyboard" bundle:nil];
View * myView = (View *) [storyboard instantiateViewControllerWithIdentifier:@"myViewName"];
[self myView animated:YES completion:nil];

ビューを下から上に上げdismissViewControllerAnimated:、逆のアニメーションを使用してビューを閉じるため、ビューは下にスライドします。

Presentスライド ダウン アニメーションを表示する方法はありますか? どんな助けでも大歓迎です!

4

2 に答える 2

1

に使用CATransactionanimationます。

: 以下のコードdependsは、UIInterfaceOrientationforPresenting a viewsliding down animationinを使用していall orienationます。

[CATransaction begin];
CATransition *transition;
transition = [CATransition animation];
transition.type = kCATransitionPush;
if(viewOrientation == UIInterfaceOrientationLandscapeLeft)
    [transition setSubtype:kCATransitionFromLeft];
else if (viewOrientation == UIInterfaceOrientationLandscapeRight)
    [transition setSubtype:kCATransitionFromRight];
else if (viewOrientation == UIInterfaceOrientationPortrait)
    [transition setSubtype:kCATransitionFromLeft];
else 
    [transition setSubtype:kCATransitionFromRight];

transition.duration = 0.0;
[self.view.layer addAnimation:transition forKey:nil]; // add animation in layer of UIView.
//Present your View here
[CATransaction commit];

EDIT : これらのメソッドでは、.So を.h ファイルcurrent orientationに追加します。UIInterfaceOrientation viewOrientation;これらの方法は、状況に応じて変更される場合があります。iOS version

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
   viewOrientation = interfaceOrientation;
   return YES; //return according to your requirement
}

-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
  viewOrientation = toInterfaceOrientation;
}
于 2013-01-18T04:39:07.357 に答える
0

もちろん、次のように独自の移行を行うことができます。

 -(IBAction)presentNext:(id)sender {

    UIViewController *next = [self.storyboard instantiateViewControllerWithIdentifier:@"Next"];
    [self.view.window insertSubview:next.view belowSubview:self.view];
    CGAffineTransform t;
    __block NSInteger xOffset, yOffset;
    switch (self.interfaceOrientation) {
        case 1:
            xOffset = 0;
            yOffset = self.view.frame.size.height;
            break;
        case 3:
            t = CGAffineTransformMakeRotation(90 * M_PI / 180);
            next.view.transform = t;
            xOffset = -self.view.frame.size.width;
            yOffset = 0;
            break;
        case 4:
            t = CGAffineTransformMakeRotation(-90 * M_PI / 180);
            next.view.transform = t;
            xOffset = self.view.frame.size.width;
            yOffset = 0;
            break;
        default:
            break;
    }

    next.view.frame = self.view.frame;
    [UIView animateWithDuration:1 animations:^{
        self.view.center = CGPointMake(self.view.center.x + xOffset, self.view.center.y + yOffset);
    } completion:^(BOOL finished) {
        [self presentViewController:next animated:NO completion:^{
            [self.view removeFromSuperview];
        }];
    }];
}
于 2013-01-18T06:06:01.977 に答える