I have some problem with 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类型的值转换为预期的参数类型字符串”我该如何解决这个问题
2 个解决方案
#1
0
Maybe I'm missing something but why are you adding this?
也许我错过了什么,但你为什么要加这个呢?
#imageLiteral(resourceName:
The correct syntax is
正确的语法是
let ground = SKSpriteNode(imageNamed: "Ground")
#2
1
I was doing :
我在做 :
profileImgView.image = UIImage(named: #imageLiteral(resourceName: "default_UserImage"))
while it should be :
虽然它应该是:
profileImgView.image = #imageLiteral(resourceName: "default_UserImage")
imageLiteral already return UIImage.
#1
0
Maybe I'm missing something but why are you adding this?
也许我错过了什么,但你为什么要加这个呢?
#imageLiteral(resourceName:
The correct syntax is
正确的语法是
let ground = SKSpriteNode(imageNamed: "Ground")
#2
1
I was doing :
我在做 :
profileImgView.image = UIImage(named: #imageLiteral(resourceName: "default_UserImage"))
while it should be :
虽然它应该是:
profileImgView.image = #imageLiteral(resourceName: "default_UserImage")