Swift从通知userInfo获取rect

时间:2015-10-05 14:12:28

标签: ios swift

在swift中,我试图从键盘通知中提取一些信息:

fun gotKeyboardShowNotification(notification:NSNotification) {
        NSLog("gotKeyboardShowNotification: \(notification)")
        let theUserInfo = notification.userInfo!
        let theFrameBegin = theUserInfo[UIKeyboardFrameBeginUserInfoKey]
        let theBeginObject = theFrameBegin!
        let theBeginRect = theBeginObject as NSRect

日志显示通知包括 UIKeyboardFrameBeginUserInfoKey =“NSRect:{{0,736},{414,271}}”;

但我似乎无法伸直:

theUserInfo is type [NSObject:AnyObject]
theFrameBegin is type AnyObject?
theBeginObject is type NSConcreteValue*
theBeginRect is type NSConcreteValue*

我尝试过各种各样的构建和构造,但还没弄明白如何从这个东西中获取CGRect!

0 个答案:

没有答案