0

我正在尝试将Apple 制作的键盘管理文档中的代码合并到我的应用程序中。到目前为止,我已经能够将 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.
}

在该行,我收到一条错误消息,显示“无法使用类型为 '(CGFloat, CGFloat)' 的参数列表调用 '-=' ”。有什么办法可以解决这个问题,还是我做错了什么?


注意:我尝试将它们都转换为浮点数,但得到错误“无法使用类型为 '($T4, $T9)' 的参数列表调用 'init' ”。当我将 as 浮点数转换为不同的变量然后减去它们时,我收到错误“无法使用类型为 '(Float, Float)' 的参数列表调用 '-=' ”。

4

1 回答 1

2

请更改let aRectvar aRect,可以更改变量。

于 2014-12-27T17:13:53.963 回答