我正在尝试将这些图像制作成动画,但模拟器在启动时总是崩溃,有人可以建议 - 我做错了什么吗? 这是我的 ViewController.swift 的样子:
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var ImageView: UIImageView!
override func viewDidLoad() {
super.viewDidLoad()
var imagesListArray: [UIImage] = []
for name in ["img1.jpg", "img2.jpg", "img3.jpg", "img4.jpg"] {
if let image = UIImage(named: name) {
imagesListArray.append(image)
}
}
ImageView.animationImages = imagesListArray;
ImageView.animationDuration = 5
ImageView.startAnimating()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
}
我肯定导入了图像(尽管即使我没有导入这也不会成为问题)。那么,那还能是什么?
在这里,我将添加我在启动时收到的异常日志:
2015-10-21 15:05:47.168 singleVshow[11922:7207193] -[UIView setAnimationImages:]: unrecognized selector sent to instance 0x7fa119531770
2015-10-21 15:05:47.172 singleVshow[11922:7207193] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason:
'-[UIView setAnimationImages:]: unrecognized selector sent to instance 0x7fa119531770'
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
如果有必要,我会添加调用堆栈。
最佳答案
该错误表明它是一个 UIView 对象正在尝试调用 setAnimationImages
。您可能需要验证 Storyboard中 UIImageView 的导出是否设置正确。您可能只想完全删除 socket 并重新创建它以确保选择 UIImageView。
关于ios - ImageView 图像动画应用程序在启动时崩溃 [SWIFT],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33258940/