gpt4 book ai didi

ios - presentViewController :animated:completion wont Animate

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:11:13 27 4
gpt4 key购买 nike

这是我的第一个问题,所以请放轻松!!

我有一个 iOS 应用程序,它有 5 个选项卡栏,每个选项卡栏都包含一个导航 Controller 。似乎无论我从哪里调用 presentViewController:animated:completion,我都没有从过渡中获得动画,呈现的 View Controller 只是出现在屏幕上!

这也发生在我从我的一个选项卡中呈现的 UIImagePickerController 上。没有呈现动画,但当我关闭它时它确实动画消失了!

这是代码示例,从代码生成的标签栏按钮发送,其操作连接到一个简单地执行此操作的方法..

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

userRegistration.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;

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

如果有人对我可以尝试的事情有任何想法,我将不胜感激!

最佳答案

我假设您希望动画在标签栏按下之间的转换期间出现。如果是这样,您将无法控制该动画,因为选项卡栏会为您管理过渡。看起来您正在尝试在 Tab 按下之间实现交叉淡入淡出。虽然你真的不能淡出旧的 View Controller ,但你可以很容易地让新的 View Controller 在出现时淡入:

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

请注意,选项卡栏已经呈现 View Controller 。您不应该尝试自己呈现 View Controller 。让选项卡栏为您管理;这就是它的用途。

关于ios - presentViewController :animated:completion wont Animate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18645184/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com