[英]Undefined symbols for architecture i386:“_OBJC_CLASS_$_TLFApplicationHelper”
[英]Swift: Undefined symbols for architecture i386: “_OBJC_CLASS_$_CGColor”
我正在嘗試為視圖的背景色設置動畫。 在animationDidStop
委托方法中,我嘗試使用CABasicAnimation
對象的toValue
屬性設置最終的背景顏色。 該代碼在編輯器中似乎正確,但是當我編譯項目時,鏈接器找不到CGColor
類。 如果我省略UIColor(CGColor: animation.toValue as CGColor!
)表達式(例如,使用const UIColor
),則該代碼有效
class ViewController: UIViewController {
@IBAction func colorSelected(sender: UIButton)
{
let animation = CABasicAnimation(keyPath: "backgroundColor")
animation.toValue = sender.backgroundColor.CGColor
animation.delegate = self
self.view.layer.addAnimation(animation, forKey: "fadeAnimation")
}
@objc override func animationDidStop(anim: CAAnimation!, finished flag: Bool) {
let animation = anim as CABasicAnimation
self.view.backgroundColor = UIColor(CGColor: animation.toValue as CGColor!)
}
}
更新:在Xcode 6的β3的代碼編譯,但一個例外方法被升高swift_dynamicCastUnknownClassUnconditional
其中toValue
屬性澆鑄到CGColor
。
這種奇怪的行為似乎與某些Xcode問題有關。
請記住,該類是CGColorRef
而不是CGColor。 CGColor是UIColor的屬性,用於獲取CGColorRef,例如[UIColor redColor].CGColor
如Apple在此論壇主題中所闡明的,這與編譯器錯誤有關。 請求並提交了雷達:17603642。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.