ios - ImageView 图像动画应用程序在启动时崩溃 [SWIFT]

标签 ios swift exception uiimageview

我正在尝试将这些图像制作成动画,但模拟器在启动时总是崩溃,有人可以建议 - 我做错了什么吗? 这是我的 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/

相关文章:

swift - 为什么这个计时器不触发?

ios - 核心数据 : no index path for table cell being reused, 单元格消失

iOS SceneKit - 为 Material 透明度添加菲涅耳效果

swift - 如何在 Swift 2.1 中使用滑动/点击(动态)为 3D 对象着色

ios - 重新排序 UIView subview

java - Android - 如何将崩溃报告发送到服务器?

.net - Outlook 2003 加载项 - 创建 WPF 窗口后应用程序关闭时出现 COM 异常

exception - 打开输入 channel 的 Ocaml 异常处理

ios - 用 UIAlertController 替换 UIAlertView

ios - 是否可以使用 Apple Store 分发未完成的 iOS 应用程序以进行封闭 Beta 测试?