UIAlertView,POP返回键盘闪现
2015-07-29 15:05
447 查看
假如有两个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];
} }
在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];
} }
相关文章推荐
- Android学习心得(9) --- ndk-build脚本参数用法
- Easyui 中的placeholder属性
- iOS UIButton按钮图片在上文字在下
- UI 总结-1 UIButton
- iOS UI第一周总结
- priority_queue(优先队列)
- iOS开发UI篇—Quartz2D使用(绘制基本图形)
- hdu5312 Sequence 三角形数的应用
- 1062. Talent and Virtue (25)
- 1062. Talent and Virtue (25)
- IOS中UITextField限制字数,特别是中文
- ios开发--UISegmentedControl分段
- hdu 5301 Buildings
- 游戏UI库
- Implement Queue using Stacks
- ios开发--UIGestureRecognizer
- iOS-UI-05 导航控制器的使用 UINavigationController
- iOS-UI-滚动视图2—分页查看功能
- 写在Demo战斗系统之前,先用原型工具做套UI第二篇-人物选择界面制作
- IOS GCD queue group