gpt4 book ai didi

ios - viewDidAppear 中动画的奇怪行为

转载 作者:行者123 更新时间:2023-11-28 22:09:34 27 4
gpt4 key购买 nike

我正在我的应用程序的 viewDidApepar 中对一个带有动画的方法进行简单调用, Storyboard中动画 View 的初始位置是 (10 , 5) - 几乎隐藏在主视图之外。

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

方法包含

[UIView animateWithDuration:0.8f delay:0.0f usingSpringWithDamping:0.5f initialSpringVelocity:1.0f options:UIViewAnimationOptionBeginFromCurrentState animations:^{
[plotView setFrame:CGRectMake(10, 40, 299, 130)];
} completion:nil];

问题:当应用程序启动时 - 一切都很好,有一个很酷的“ Spring ”效果,但是当我推到另一个 View 并返回主视图时,动画方法是被调用时,日志显示 plotView 已将 frame.origin 更改为 (10,40),但它仍然停留在 (10,5) 其在 Storyboard上的初始位置。

最佳答案

替换

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

-(void) viewDidLayoutSubviews{
[super viewDidLayoutSubviews];
[self doTheAnimation];
}

关于ios - viewDidAppear 中动画的奇怪行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23245845/

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