CaptainCOOLGUY CaptainCOOLGUY - 1 year ago 115
Swift Question

How to find keyboard height using Swift

let frame = (info[UIKeyboardFrameEndUserInfoKey] as NSValue) as CGRect

does not work. Anybody know why this does not function as expected?

Error: 'NSValue' not convertible to 'CGRect'

Keep in mind that something like:

let curve = (info[UIKeyboardAnimationCurveUserInfoKey] as NSValue) as UInt

works fine.

Edit: Even Apple documentation indicates this is a glitch because of the following comment in Cocoa for

// NSValue of CGRect

Edit2: The debugger defines it as an NSConcreteValue. How can I convert it to a CGRect?

Answer Source
let frame = (info[UIKeyboardFrameEndUserInfoKey] as NSValue).CGRectValue()
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download