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];
        }
    }

    好了的效果如下

  • 相关阅读:
    设计模式 创建型 单例模式
    设计模式 创建型 抽象工厂模式
    设计模式六大原则
    设计模式 创建型 工厂方法模式
    设计模式 创建型 简单工厂模式
    Junit TDD
    覆盖索引
    多列索引 单列索引
    JDBC PreparedStatement Statement
    常用·SQL
  • 原文地址:https://www.cnblogs.com/Apologize/p/5764806.html
Copyright © 2011-2022 走看看