我收到以下错误:在调用中缺少参数#1的参数。我正在尝试将currentConfiguration[0]
函数中panGesture
的值存储到currentColor
函数中的变量getRandomColor
。有任何想法吗?我相信解决方案可能很简单,但我对Swift功能并不太熟悉。
func getRandomColor() -> UIColor {
let colors = [UIColor.redColor(),
UIColor.blueColor(),
UIColor.greenColor(),
UIColor.yellowColor(),
UIColor.purpleColor(),
UIColor.magentaColor()]
// Generate a random index
let randomIndex = Int(arc4random_uniform(UInt32(colors.count)))
// Get a random item
let randomColor = colors[randomIndex]
var currentColor = panGesture()
return randomColor
}
func panGesture(sender: UIPanGestureRecognizer) -> (UIColor?) {
let translation = sender.translationInView(sender.view!)
let face1 = UIColor.redColor()
let face2 = UIColor.blueColor()
let face3 = UIColor.greenColor()
let face4 = UIColor.yellowColor()
let face5 = UIColor.purpleColor()
let face6 = UIColor.magentaColor()
let viewColor = sceneSetup()
//Initialize array to store current cube configuration i.e. face location
var currentConfiguration = [face1,face2,face3,face4,face5,face6]
var updatedConfiguration = [face1,face2,face3,face4,face5,face6]
return currentConfiguration[0]
}
答案 0 :(得分:0)
panGesture()
根据其定义获取参数。您的电话var currentColor = panGesture()
不提供电话。
另请注意,panGesture()
会返回UIColor?
,您必须在从getRandomColor()
返回之前解包。