首页 > 其他 > 详细

UIAlertView,POP返回键盘闪现

时间:2015-07-29 15:39:40      阅读:2601      评论:0      收藏:0      [点我收藏+]

假如有两个ViewController: A 和 B(使用了UINavigationController), 在B中有一个TextField, 一个Button.(在ARC模式下) 在Button调用的方法中创建一个UIAlertView, 在AlertView的代理方法clickedButtonAtIndex中实现pop到A. 也写了[_textField resignFirstResponder];语句.

在TextField中输入时, 键盘弹出, 在键盘不回收的情况下, pop到A, 过1秒中, A就会闪现键盘(就是B的界面上的键盘), 键盘消失时, 程序会执行B的dealloc方法.

如果把UIAlertView替换成UIAlertController的话, 键盘就会在B中先闪现, 再推到A界面. 如果直接在Button调用的方法内实现pop到A(不使用AlertView), 就不会出现这种情况

原因是因为iOS 8.3,dismiss alert view时系统会尝试恢复之前的keyboard input。

所以你要等键盘完全收起之后再pop或者push。直接dispatch_after个0.25秒再执行pop或者push。至于为什么是0.25秒,因为系统键盘收起的duration就是0.25秒。别问我怎么知道的。

解决方法: -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {

if (1 == buttonIndex) {

[self performSelector:@selector(popVC) withObject:nil afterDelay:0.25];

} }

UIAlertView,POP返回键盘闪现

原文:http://www.cnblogs.com/android-wuwei/p/4685960.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!