此行let userInfo = notification.userInfo as! NSDictionary
我得到一个警告:Cast from '[NSObject : AnyObject]?' to unrelated type 'NSDictionary' always fails
从'[NSObject:AnyObject]中投射?'无关型“的NSDictionary”总是失败
我尝试使用let userInfo = notification.userInfo as! Dictionary<NSObject: AnyObject>
取代let userInfo = notification.userInfo as! NSDictionary
。但是我收到一个错误:Expected '>' to complete generic argument list
。如何解决警告。
的Xcode 7.1 OS X约塞米蒂
这是我的代码:
func keyboardWillShow(notification: NSNotification) {
let userInfo = notification.userInfo as! NSDictionary //warning
let keyboardBounds = (userInfo[UIKeyboardFrameEndUserInfoKey] as! NSValue).CGRectValue()
let duration = (userInfo[UIKeyboardAnimationDurationUserInfoKey] as! NSNumber).doubleValue
let keyboardBoundsRect = self.view.convertRect(keyboardBounds, toView: nil)
let keyboardInputViewFrame = self.finishView!.frame
let deltaY = keyboardBoundsRect.size.height
let animations: (()->Void) = {
self.finishView?.transform = CGAffineTransformMakeTranslation(0, -deltaY)
}
if duration > 0 {
} else {
animations()
}
}
只使用Swift原生字典 –
我尝试使用'let userInfo = notification.userInfo as! Dictionary'但它是错误的,我得到一个错误。 –
rose
为什么要输入铸件? – vadian