xcode 无法将 UIImage 类型的值转换为预期的参数类型字符串
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/38297259/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 09:01:29 来源:igfitidea点击:
cannot convert value of type UIImage to expected argument type string
提问by Gh0st
I have some problem with swift.
我对 swift 有一些问题。
Ground = SKSpriteNode(imageNamed: "#imageLiteral(resourceName: "Ground")")
Here it says "cannot convert value of type UIImage to expected argument type string" how can i fix this
这里说“无法将 UIImage 类型的值转换为预期的参数类型字符串”我该如何解决这个问题
采纳答案by Luca Angeletti
Maybe I'm missing something but why are you adding this?
也许我遗漏了一些东西,但你为什么要添加这个?
#imageLiteral(resourceName:
The correct syntax is
正确的语法是
let ground = SKSpriteNode(imageNamed: "Ground")
回答by Gh0st
I was doing :
我在做 :
profileImgView.image = UIImage(named: #imageLiteral(resourceName: "default_UserImage"))
while it should be :
虽然它应该是:
profileImgView.image = #imageLiteral(resourceName: "default_UserImage")