【发布时间】:2015-02-03 10:50:09
【问题描述】:
我为 Objective-c 找到了这个解决方案:Scroll UITextField above Keyboard in a UITableViewCell on a regular UIViewController,但我无法将其调整为 swift。
func textViewShouldBeginEditing(textView: UITextView) -> Bool {
var pointInTable:CGPoint? = textView.superview?.convertPoint(textView.frame.origin, toView: tableView)
var contentOffset:CGPoint = tableView.contentOffset
contentOffset.y = pointInTable?.y - textView.inputAccessoryView?.frame.size.height
}
我得到错误:
Value of optional type 'CGFloat?' not unwrapped; did you mean to use '!' or '?'?
当我使用 !或者 ?我得到错误: 后缀 '?' 的操作数应该有可选类型;类型是'CGFloat'
【问题讨论】: