SwiftGif:这个名为“one”的图像不存在

问题描述 投票:1回答:1

按照视频中的说明:https://www.youtube.com/watch?v=Rm61mxcSD4U&t=95s

添加了我的动画GIF文件one.GIF

尝试运行,但得到错误:

SwiftGif:这个名为“one”的图像不存在。

import UIKit

class ViewController: UIViewController {

    @IBOutlet weak var gifView: UIImageView!

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.

        gifView.loadGif(name: "one")
    }
}
swift xcode
1个回答
1
投票

在您的文件one.GIF中,扩展名全部为大写。但是,你可以在the source code看到它正在寻找小写的.gif

你需要将one.GIF重命名为one.gif


来自Getting References to Bundle Resources: The Bundle Search Pattern

重要提示:在bundle目录中搜索资源文件时,bundle接口会考虑大小写。这种区分大小写的搜索甚至发生在文件系统(例如HFS +)上,这些文件系统在文件名方面不区分大小写。

© www.soinside.com 2019 - 2024. All rights reserved.