【问题标题】:Swift animate UIView with multiple optionsSwift 动画 UIView 与多个选项
【发布时间】:2014-12-01 13:51:56
【问题描述】:

swift 在 UIView 动画时如何处理多个选项?我试过了

UIView.animateWithDuration(0.2, delay: 0.0, options: .Repeat | .Autoreverse, animations: {self.alpha = 0.0}, completion: nil)

但似乎将| 与按位运算符混淆:

Undefined symbols for architecture i386:
 "__TFSsoi1oUSs17_RawOptionSetType_USs21BitwiseOperationsTypeSs9Equatable__FTQ_Q__Q_", referenced from:
      __TFC17TextDrawing10cursorViewW8blinkingSb in cursorView.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

我正在使用来自 AppStore 的最新 Xcode 版本。

【问题讨论】:

  • 看来代码没有问题。您是否尝试过删除项目的派生数据并清理构建?
  • 我清理了构建(产品 -> 清理)并删除了派生数据。它仍然给出同样的错误。
  • 也尝试一个干净的构建文件夹:项目 ->(按住 Alt 键)-> 清理构建文件夹
  • 您能否再次检查一下您为我们提供的 Xcode 的确切构建版本号,好吗? (Xcode 菜单/关于 Xcode)你能在一个新的、最小的项目中重现这个问题吗? (我同意其他人的观点:我使用 | 来组合 UIViewAnimationOptions 值就好了......)我想知道代码/构建设置中是否还有其他东西会混淆编译器/链接器......
  • 另外,看起来您正在为模拟器(即 i386)构建 - 您在构建真实设备时遇到同样的问题吗?

标签: ios uiview swift xcode6 uiviewanimation


【解决方案1】:

the docs看来你的做法是正确的?

您是否尝试将选项括在括号中?

要么这样,要么先将选项放入变量中然后尝试?

【讨论】:

  • 我都试过了,编译的时候报同样的错误。
  • @Hristo 您是否尝试过完全引用它们?即把UIViewAnimationOptions.Repeat等...
【解决方案2】:

这是我的工作代码:

        UIView.animateWithDuration(0.5, delay: 0.0, options: UIViewAnimationOptions.Autoreverse | UIViewAnimationOptions.Repeat, animations: { () -> Void in
            disc.layer.transform = CATransform3DMakeScale(1.0, 1.0, 1.0)
            }) { (success) -> Void in
        }

【讨论】:

    【解决方案3】:

    斯威夫特 2

    UIView.animateWithDuration(0.2, delay: 0.0, options: [.Repeat, .Autoreverse], animations: {self.alpha = 0.0}, completion: nil)
    

    斯威夫特 3、4、5

    UIView.animate(withDuration: 0.2, delay: 0.0, options: [.repeat, .autoreverse], animations: {self.alpha = 0.0}, completion: nil)
    

    【讨论】:

      【解决方案4】:

      预览答案现在很快就不起作用了。 @mxcl 给出了很好的答案。

      如果尽管你想使用这个表单,你必须检索 rawValue 并使用包含 OR 掩码重建一个新的 UIViewAnimationOptions。

      UIViewAnimationOptions(rawValue:(UIViewAnimationOptions.Autoreverse.rawvalue | UIViewAnimationOptions.Repeat.rawValue))
      

      【讨论】:

        【解决方案5】:

        斯威夫特 3: 测试并正常:

        UIView.animate(withDuration: 0.2, delay: 0.0, options: [.repeat, .autoreverse], animations: {
                    }, completion: nil)
        

        【讨论】:

          猜你喜欢
          • 2014-07-27
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多