[英]Swift 5 Error: 'UIImage' is ambiguous for type lookup in this context
When I try to create a UIImage extension in Swift 5, like this:当我尝试在 Swift 5 中创建 UIImage 扩展时,如下所示:
extension UIImage {
}
I get this error:我收到此错误:
'UIImage' is ambiguous for type lookup in this context
What causes this and how do I avert it?这是什么原因造成的,我该如何避免? Thanks!谢谢!
I found this in 3 Swift files at the end of my code:我在代码末尾的 3 个 Swift 文件中找到了这个:
class UIImage {
private func newBorderMask(_ borderSize: Int, size: CGSize) -> CGImageRef? {
}
}
So I saw that the code was redeclaring class UIImage
after the extension UIImage
.所以我看到代码在extension UIImage
之后重新声明了class UIImage
extension UIImage
。 In each case, I moved the private func
into the extension UIImage
and removed the class UIImage
from the code.在每种情况下,我都将private func
移到extension UIImage
并从代码中删除了class UIImage
。 This removed all of the 'UIImage' is ambiguous for type lookup in this context
errors throughout my project.这删除了所有'UIImage' is ambiguous for type lookup in this context
整个项目'UIImage' is ambiguous for type lookup in this context
错误中的'UIImage' is ambiguous for type lookup in this context
。
You need你需要
import UIKit
at the top of the file在文件顶部
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.