-1
所以每當我有這樣的:‘?UIImage的’Swift Xcode 6.1打破了我的代碼|操作數錯誤
let result = SKScrollingNode(color: UIColor.clearColor(), size:CGSizeMake(CGFloat(containerWidth), image.size.height));
我得到一個編譯錯誤的image.size.height,告訴我」沒有一個名爲「大小」,儘管它確實
任何想法成員這意味着什麼,以及如何解決它
感謝
整個代碼片段:!
class func scrollingNode(imageNamed: String, containerWidth: CGFloat) -> SKScrollingNode {
let image = UIImage(named: imageNamed);
let result = SKScrollingNode(color: UIColor.clearColor(), size: CGSizeMake(CGFloat(containerWidth), image.size.height));
result.scrollingSpeed = 1.0;
var total:CGFloat = 0.0;
while(total < CGFloat(containerWidth) + image.size.width!) {
let child = SKSpriteNode(imageNamed: imageNamed);
child.anchorPoint = CGPointZero;
child.position = CGPointMake(total, 0);
result.addChild(child);
total+=child.size.width;
}
return result;
'UIImage'有'size'。 'UIImage?'不。 – matt 2014-11-03 15:36:52
仍然無效:UIImage.size.height。獲取相同的錯誤,所以這不是問題 – Sarah 2014-11-03 15:39:06
看看這個答案:http://stackoverflow.com/questions/26582035/in-xcode-6-1-uiimage-does-not-have-a-member- named-size-error – 2014-11-03 15:44:50