zoukankan      html  css  js  c++  java
  • ios8以后,使用UIAlertViw时pop/push页面后,键盘闪一下的问题

    代码为

    UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"" message:@"感谢你对我们提出的意见或建议,你的支持就是我们进步的动力!" delegate:self cancelButtonTitle:@"我知道了" otherButtonTitles:nil, nil];
    [alert show];
    
    -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
        if (buttonIndex==0) {
            [self backForward];
        }
    }

    效果如图

    这是因为alertView的动画和键盘动画起冲突了
    解决方法分为两种
    ①用UIAlertController,适用于ios8以后
    ②若还是想用UIAlertView,那么可以用如下方法

    alertview show的时候写个主线程延迟,pop也延迟

    UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"" message:@"感谢你对我们提出的意见或建议,你的支持就是我们进步的动力!" delegate:self cancelButtonTitle:@"我知道了" otherButtonTitles:nil, nil];
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.4f * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [alert show];
    });
    -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
        if (buttonIndex==0) {
            [self performSelector:@selector(backForward) withObject:nil afterDelay:0.25f];
        }
    }

    好了的效果如下

  • 相关阅读:
    62 ip与int类型的转换
    60再谈指针
    59任由制转换
    58进制转换工具
    吉哥工作
    apple
    找第一个非0元素的位置
    若干个数据之和 不考虑溢出
    汇编程序w=x*y+z-200
    4位bcd数转换为2进制数
  • 原文地址:https://www.cnblogs.com/Apologize/p/5764806.html
Copyright © 2011-2022 走看看