gpt4 book ai didi

ios - Poptorootviewcontroller 延迟

转载 作者:行者123 更新时间:2023-11-28 19:55:03 26 4
gpt4 key购买 nike

我有一个执行 poptorootviewcontroller 的方法“test”。我想在 poptorootviewcontroller 的动画之前放一些延迟。这是我的代码:

-(void)test{
[UIView animateWithDuration:5.0
delay: 2.5
options: UIViewAnimationOptionCurveEaseIn
animations:^{
[self.navigationController popToRootViewControllerAnimated:NO];
}
completion:nil];
}

但它不起作用。有什么帮助吗?谢谢!

最佳答案

您发布的代码用于执行动画,而不是延迟。

一个好的解决方案是使用dispatch_after:

-(void)test{
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self.navigationController popToRootViewControllerAnimated:NO];
});

2.5 替换为您想要的任何延迟。

关于ios - Poptorootviewcontroller 延迟,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26978577/

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