我想启动一个UITableView
fromCGRectMake
函数的实例,但是当我尝试使用常量而不是直接分配一个 new 来启动它时Int
,例如:
UITableView(frame: CGRectMake(20, HEIGHT_OF_STATUS_AND_NAVIGATION_BAR + 120, tableWidth, tableHeight)
,然后我得到一个错误:Int is not convertible to CGFloat
。
所以我将其更改为以下代码:
UITableView(frame: CGRectMake(20, (HEIGHT_OF_STATUS_AND_NAVIGATION_BAR + 120) as CGFloat, tableWidth as CGFloat, tableHeight as CGFloat)) // `tableWidth` and `tableHeight` are both of type `Int`.
,然后我得到一个错误:Cannot invoke + with an argument of type CGRect
。
当然,我可以通过分配来启动它Int
,例如CGRectMake(20 + 300 + 12, 44 + 120, 300, 480)
. 但我想使用常量和变量。
那么错误是什么意思呢?我该如何解决?
我使用 Xcode 6 beta 6。