我試圖與swift
幻燈片應用程序,但我有一個問題,在 我main.storyboard
添加一個imageview
和一個按鈕,當此按鈕,用戶點擊幻燈片將動畫。無法識別的選擇發送到實例與斯威夫特
我在viewController.swift
@IBOutlet var ImageView: UIImageView!
@IBOutlet var animateBtn: UIButton!
@IBAction func animateBtnClicked(sender: UIButton) {
startAnimation()
}
var imageList:[UIImage]=[]
override func viewDidLoad() {
super.viewDidLoad()
for i in 1 ... 3{
let imagename="\(i).jpg"
imageList.append(UIImage(named: imagename)!)
}
}
func startAnimation()->(){
if !ImageView.isAnimating()
{
ImageView.animationImages=[imageList]
ImageView.startAnimating()
animateBtn.setTitle("Stop Animation", forState:UIControlState.Normal)}
else
{
ImageView.stopAnimating()
}
}
寫了這個代碼在appdelegate.swift我沒寫任何代碼。
但是當我點擊該按鈕,顯示此消息錯誤
2014-12-02 09:54:55.693 #4 animation photo[921:613] -[Swift._NSSwiftArrayImpl _isResizable]: unrecognized selector sent to instance 0x7f82126615d0
2014-12-02 09:54:55.698 #4 animation photo[921:613] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Swift._NSSwiftArrayImpl _isResizable]: unrecognized selector sent to instance 0x7f82126615d0'
如果使用'ImageView.animationImages = imageList'而不是'ImageView.animationImages = [imageList]',會發生什麼?我不清楚你爲什麼似乎將數組包裝在一個數組中...... – 2014-12-02 08:02:29