问题描述
查看了uikeyboardanimationdurationuserinfokey,但我只是找不到任何地方如何将其设置为自定义值.
looked intouikeyboardanimationdurationuserinfokey but i just can't find anywhere how to set it to a custom value.
推荐答案
uikeyboardanimationdurationuserinfokey 是保存动画时长的字典键的 const 字符串标识符,因此无法轻易更改.
uikeyboardanimationdurationuserinfokey is a const string identifier for the dictionary key that holds the animation duration, so there is no way to change it easily.
让键盘在没有动画的情况下出现的一种方法是观察键盘通知并在动画即将出现时禁用动画,然后重新启用它们.当然,这也会禁用任何其他动画.
one way to make the keyboard appear without animation is to observe the keyboard notifications and disable animation when it's about to appear and then reenable them. this, of course, disables any other animation as well.
[[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(willshowkeyboard:) name:uikeyboardwillshownotification object:nil]; [[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(didshowkeyboard:) name:uikeyboarddidshownotification object:nil]; - (void)willshowkeyboard:(nsnotification *)notification { [uiview setanimationsenabled:no]; } - (void)didshowkeyboard:(nsnotification *)notification { [uiview setanimationsenabled:yes]; }
然后 uikeyboardwillhidenotification/uikeyboarddidhidenotification 通知也是如此.
and then then the same for uikeyboardwillhidenotification/uikeyboarddidhidenotification notifications.