ios - viewDidAppear 中动画的奇怪行为

标签 ios uiviewanimation viewdidappear

我正在我的应用程序的 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/

相关文章:

ios - Swift - 使用 viewDidAppear 中的新信息重新加载 UIPageViewController

ios - 什么可能导致此 "Fatal Exception: CALayerInvalidGeometry CALayer bounds contains NaN: [nan nan; nan nan]"崩溃?

ios - 使用 NSKeyedUnarchiver 解码 URL 对象数组

ios - 为什么 `pod install`会改变PODS_ROOT路径?

ios - 自动布局约束更改不动画

ios - 延迟 UITableView 隐藏 UITableViewCells

ios - UIButton touchDragEnter 和 touchDragExit 调用太频繁

iOS viewWillAppear 错误 : "view is not in the window hierarchy"

ios - UIViewController 在 vi​​ewWillAppear 和 viewDidAppear 之间调整自身大小?

ios - UITableViewCell 样式和 dequeueReusableCellWithIdentifier