找不到“Init"的重载 - UIImage [英] Could Not Find Overload for 'Init' - UIImage

查看:31
本文介绍了找不到“Init"的重载 - UIImage的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我升级到最新版本的 Xcode,现在我收到无法找到接受提供的参数的 'Init' 的重载"错误.导致此错误的行是:

I upgraded to the latest version of Xcode and now I'm getting a "Could not find an overload for 'Init' that accepts the supplied argument" error. The line that's causing this error is:

leftDigitImage.animationImages = [UIImage(named: "blink_anim.gif"),UIImage(named: "empty led.png")]

leftDigitImage 是一个定义为:

leftDigitImage is an outlet that's defined as:

@IBOutlet weak var leftDigitImage: UIImageView!

它在以前版本的 Xcode 中运行良好.

It worked fine in the previous version of Xcode.

推荐答案

这样写:

leftDigitImage.animationImages = [UIImage(named: "blink_anim.gif")!, UIImage(named: "empty led.png")!]

问题是 UIImage init(named:) 现在返回一个可选项,所以你需要解开它们.

The problem is that UIImage init(named:) now returns an optional, so you need to unwrap them.

这篇关于找不到“Init"的重载 - UIImage的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆