小编Ben*_*y B的帖子

UIKeyboardDidShowNotification多次调用,有时键盘尺寸不正确

我试图在键盘出现/更改时在键盘上方移动UITextView.假设我显示英文键盘,然后直接切换到中文键盘(比标准英文键盘高).在这种情况下,我的文本视图总是显得太高(肉眼看来,文本视图被中文键盘"输入附件视图"的大小错误地偏移.我发布的图片却缺乏声誉所以:)).当我的应用程序收到UIKeyboardDidShowNotification(使用UIKeyboardFrameEndUserInfoKey获取高度)时,我正在调整文本视图位置,经过一些调查后,UIKeyboardDidShowNotification被多次调用,通常是键盘尺寸不正确(我已经NSLogged了userInfo字典).我在ViewWillAppear中注册我的键盘通知,并在ViewWillDisappear中取消注册.我无法确定导致此通知多次触发的原因; 我的理解是,只有在键盘完成显示后才会触发此通知一次.另外需要注意:我在响应UIKeyboardDidShowNotification的方法中使用了NSLogged"self",它实际上始终是相同的View Controller对象.

但是,即使多次触发此通知,我仍然不明白为什么某些通知的键盘高度会有所不同.其中一个通知始终具有正确的高度,但是当它不是最后一个通知时,文本视图最终会出现在错误的位置.任何有关如何进一步排除故障的见解将非常感激!

编辑:我测试的越多,特别是中文键盘的问题就越多.每当我将键盘从英文切换到中文时,我得到三个UIKeyboardWillShowNotifications:

2014-12-24 22:49:29.385 Example[1055:421943] info dictionary: {
UIKeyboardAnimationCurveUserInfoKey = 0;
UIKeyboardAnimationDurationUserInfoKey = 0;
UIKeyboardBoundsUserInfoKey = "NSRect: {{0, 0}, {320, 252}}";
UIKeyboardCenterBeginUserInfoKey = "NSPoint: {160, 460}";
UIKeyboardCenterEndUserInfoKey = "NSPoint: {160, 442}";
UIKeyboardFrameBeginUserInfoKey = "NSRect: {{0, 352}, {320, 216}}";
UIKeyboardFrameEndUserInfoKey = "NSRect: {{0, 316}, {320, 252}}";
}
2014-12-24 22:49:29.408 Example[1055:421943] info dictionary: {
UIKeyboardAnimationCurveUserInfoKey = 0;
UIKeyboardAnimationDurationUserInfoKey = 0;
UIKeyboardBoundsUserInfoKey = "NSRect: {{0, 0}, {320, 216}}";
UIKeyboardCenterBeginUserInfoKey = "NSPoint: {160, 442}";
UIKeyboardCenterEndUserInfoKey = "NSPoint: {160, 460}"; …
Run Code Online (Sandbox Code Playgroud)

uikeyboard nsnotification ios

14
推荐指数
3
解决办法
8715
查看次数

Angular/CSS - 动态添加新元素时以动画方式移动内容

这里是角度动画菜鸟。

我可以使用 成功地将内容制作成动画到页面上ngAnimate。但是,当我的新内容滑入时,其下方的所有内容都会跳至新位置。同样,当新内容被删除时,后续内容会跳回来。是否有一种有角度的方式来动画以下内容的新位置?

<button class="button" ng-if="typingResponse">
    Submit!
</button>
<div class="response-section">
  <label class="item item-input item-stacked-label">
    <span class="input-label">Response</span>
    <textarea></textarea>
  </label>
</div>


.button.ng-enter {
  -webkit-animate: slideInLeft 1s;
  animation: slideInLeft 1s;
}
.button.ng-leave {
  -webkit-animate: slideOutLeft 1s;
  animation: slideOutLeft 1s;
}
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

css css-transitions angularjs ng-animate ionic-framework

5
推荐指数
1
解决办法
1199
查看次数