2

this is my first question so please go easy!!

I have an iOS app that has 5 tab bars, each of which contains a Navigation controller. It seems that no matter where I call presentViewController:animated:completion from, I get no animation from the transition, the presented view controller just appears on screen!

This is also happening with my UIImagePickerController that I am presenting from one of my tabs. No presenting animation, but when i dismiss it it DOES animate away!

Here is a sample of the code, sent from a code generated tab bar button, with its action hooked up to a method which simply does this..

UserRegistrationViewController *userRegistration = [[UserRegistrationViewController alloc] init];

userRegistration.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;

[self presentViewController:userRegistration animated:YES completion:nil];

If anyone has ANY ideas of things that I could try I would be most grateful!

4

1 回答 1

2

我假设您希望在标签栏按下之间的过渡期间发生动画。如果是这样,您几乎无法控制该动画,因为标签栏会为您管理过渡。看起来您正试图在标签按下之间实现交叉淡入淡出。虽然你真的不能淡出旧的视图控制器,但是你可以很容易地让新的视图控制器在它出现时淡入:

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];

    //Set the view to transparent before it appears.
    [self.view setAlpha:0.0f];
}

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];

    //Make the view fade in.  Set Opaque at the end for a performance boost.
    [UIView animateWithDuration:0.5f
                     animations:^{
                         [self.view setAlpha:1.0f];
                         [self.view setOpaque:YES];
                     }];
}

请注意,标签栏已经显示了视图控制器。您不应该尝试自己呈现视图控制器。让标签栏为您管理;这就是它的用途。

于 2013-09-06T02:33:01.047 回答