let r:Int = Int( CGFloat(y - (Int(_gridLowerLeftCorner.y) + _margin)) / CGFloat (_gridHeight) * (_numRows))
let c:Int = Int( CGFloat(x - (Int(_gridLowerLeftCorner.x) + _margin)) / CGFloat (_gridWidth) * (_numCols))
我无法找到接受提供的参数的init的重载,有人知道为什么吗?
答案 0 :(得分:0)
1)可能因为常量(let)将其更改为var
2)可能是Int和CGFloat之间的类型不匹配。
答案 1 :(得分:0)
我相信您输入了Int
而不是CGFloat
:
let r:Int = Int( CGFloat(y - (Int(_gridLowerLeftCorner.y) + _margin)) / CGFloat (_gridHeight) * (_numRows))
let c:Int = Int( CGFloat(x - (Int(_gridLowerLeftCorner.x) + _margin)) / CGFloat (_gridWidth) * (_numCols))
应该是
let r:Int = Int( CGFloat(y - (CGFloat(_gridLowerLeftCorner.y) + _margin)) / CGFloat (_gridHeight) * (_numRows))
let c:Int = Int( CGFloat(x - (CGFloat(_gridLowerLeftCorner.x) + _margin)) / CGFloat (_gridWidth) * (_numCols))