【发布时间】:2014-12-27 17:07:25
【问题描述】:
我正在尝试将 Apple 制作的 Keyboard Management 文档中的代码合并到我的应用程序中。到目前为止,我已经能够将 Objective-C 解析为 Swift,但是有一行我遇到了问题。这是在上下文中(最后一行是发生错误的地方):
func keyboardWasShown(aNotification: NSNotification) {
let info = aNotification.userInfo as NSDictionary!
let kbSize = (info[UIKeyboardFrameBeginUserInfoKey] as? NSValue)?.CGRectValue()
let contentInsets = UIEdgeInsetsMake(0.0, 0.0, kbSize!.height, 0.0)
scrollView.contentInset = contentInsets
scrollView.scrollIndicatorInsets = contentInsets
let aRect = view.frame
aRect.size.height -= kbSize!.height //This line gives me trouble.
}
在该行,我收到一条错误消息,显示“Cannot invoke '-=' with an argument list of type '(CGFloat, CGFloat)'”。有什么办法可以解决这个问题还是我做错了什么?
注意:我尝试将它们都转换为浮点数,但得到错误“无法使用类型为'($T4, $T9)'的参数列表调用'init'”。当我将 as 浮点数转换为不同的变量然后减去它们时,我收到错误“Cannot invoke '-=' with an argument list of type '(Float, Float)'”。
【问题讨论】:
标签: ios swift geometry cgrect cgfloat