0

しばらく探していたのですが、基本的には「presentModalViewController」のアニメーションが欲しいのですが、逆に…画面の上部を下部に落としてページを表示させたいです。それが何と呼ばれているか知っている人はいますか?

これは私がこれまでに持っているコードですが、あまりにも早く発生します...どうすれば遅くなりますか?

-(void)gotToCreateGameViewController{
CreateNewGameViewController *newGame = [[CreateNewGameViewController alloc]initWithNibName:@"CreateNewGameViewController" bundle:nil];
self.createNewGameViewController = newGame;
createNewGameViewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical; 
[self presentModalViewController:newGame animated:YES];
[self.view insertSubview:newGame.view atIndex:0];

[newGame release];
4

3 に答える 3

2

私はあなたが探していると思います:UIModalTransitionStyleCoverVertical

Presentation Transition Styles
Transition styles available when presenting view controllers.

typedef enum {
        UIModalTransitionStyleCoverVertical = 0,
        UIModalTransitionStyleFlipHorizontal,
        UIModalTransitionStyleCrossDissolve,
        UIModalTransitionStylePartialCurl,
} UIModalTransitionStyle;

下から上に移動して表示し、却下すると上から下に移動します。上から下に移行するには、自分でロールするか、下にある宛先vcから開始して、開始vcをモーダルに提示する必要があります。

于 2012-04-24T17:38:35.307 に答える
1

このコードを試してください

  -(void)gotToCreateGameViewController{
        CreateNewGameViewController *newGame = [[CreateNewGameViewController alloc]initWithNibName:@"CreateNewGameViewController" bundle:nil];
        self.createNewGameViewController = newGame;

        CATransition *transition = [CATransition animation];
        transition.duration = 0.05;
        transition.timingFunction = [CAMediaTimingFunction      
        functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
        transition.type =kCATransitionMoveIn;
        CATransition *transition = [CATransition animation];
        transition.duration = 0.05;
        transition.timingFunction = [CAMediaTimingFunction      
        functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
        transition.type =kCATransitionMoveIn;
        transition.subtype =kCATransitionFromTop;

        transition.delegate   = self;

        transition.subtype =kCATransitionFromTop;

        transition.delegate = self;


        [self presentModalViewController:newGame animated:NO];
        [self.view insertSubview:newGame.view atIndex:0];

        [self.view.layer addAnimation:transition forKey:nil]; 

        [newGame release];

UIModalTransitionStyleはiPadアプリケーションでのみ機能することに注意してください。ドキュメントを参照してください。

于 2012-04-24T18:18:34.040 に答える
0

私のハックな答え:

最初のビューを y = 960 に移動し (おそらく別のビューを追加してから、すべてをそのビューにカット アンド ペーストする必要があります)、2 番目のビューを y = 0 に配置すると、次のコードを実装できます。BOOL をインスタンス化した後 (私は mine と呼びましたmovedUp):

-(void)moveView:(float)d{
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:d];  

    CGRect rect = self.view.frame;
    if (!movedUp)
    {
        rect.origin.y -= 960;
        rect.size.height += 960;
    }
    else
    {
        // revert back to the normal state.
        rect.origin.y += 960;
        rect.size.height -= 960;
    }
    self.view.frame = rect;

    [UIView commitAnimations];
    movedUp = !movedUp;
}
- (void)viewDidAppear:(BOOL)animated
{
    [self moveView:0.0];
    [super viewDidAppear:animated];
}

次に、両方のボタン (各ビューに 1 つ) を次のように接続しました。

-(IBAction)setViewMovedUp:(id)sender
{
    [self moveView:0.5];
}
于 2012-04-24T19:50:13.150 に答える