swift - viewDidAppear() 在每次点击时运行

标签 swift viewdidappear

我正在尝试为两个文本字段和一个标签创建动画幻灯片。然而,出于某种原因,每次您尝试单击文本字段时,viewDidAppear() 函数都会运行,导致它们继续动画。有人有什么想法吗?

这是我的函数代码:

override func viewDidAppear(animated: Bool)
{
    //Some Code here
    UIView.animateWithDuration(1.5, delay: 0.5,
                               usingSpringWithDamping: 0.3,
                               initialSpringVelocity: 0.5,
                               options: [], animations: {
                                self.Email.center.x += 475
                                self.Password.center.x -= 400
        }, completion: nil)

    UIView.animateWithDuration(2.0, delay: 2.0,
                               options: [],
                               animations: {
                                self.LoginButton.alpha = 1.0
        }, completion: nil)
    UIView.animateWithDuration(1.5, delay: 0.5,
                               usingSpringWithDamping: 0.3,
                               initialSpringVelocity: 0.5,
                               options: [], animations: {
                                self.LoginL.center.y += 100
        }, completion: nil)

}

最佳答案

我们发现问题出在 ViewController 生命周期 - 它需要调用 super.viewDidAppear(animated)

关于swift - viewDidAppear() 在每次点击时运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42018323/

相关文章:

iphone - 如何在viewDidAppear中给UIView添加动画?

iphone - iOS - 当 UIView 出现在屏幕上时,它调用什么方法?

ios - GID didSignInFor 实际在哪里登录了用户?

objective-c - Touch ID for KeyChain 无 PIN 回退

ios - Grand Central Dispatch、viewWillAppear、viewDidAppear 执行顺序困惑

ios - 在 SWIFT 中推送之前如何加载 View ?

ios - 为什么 viewDidAppear 没有调用?

ios - 如何绘制相对于 UIView 大小的点网格?

ios - 错误: UICollectionView must be initialized with a non-nil layout parameter

ios - Swift 中的类型检查和验证