【问题标题】:could not find an overload for init that accepts supplied arguments找不到接受提供的参数的 init 重载
【发布时间】:2014-07-01 05:57:38
【问题描述】:
        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 重载,有人知道为什么吗?

【问题讨论】:

    标签: swift


    【解决方案1】:

    1) 可能是因为 constant(let) 改成 var

    2) 可能是 Int 和 CGFloat 之间的类型不匹配。

    【讨论】:

      【解决方案2】:

      我相信你输入的是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))
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2014-12-18
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多