加在window上的view 出现一闪而过的情况

加在window上的view 出现一闪而过的情况

主要是因为界面上也添加了UIAlertView

在UIAlterView的代理方法中 -(void)alertView:(UIAlertView*)alertView clickedButtonAtIndex:(NSInteger)buttonIndex

 添加一个UIView到[[UIApplication sharedApplication].keyWindow上,却只出现了0.5秒左右就消失

在这里,我们需要注意,

在有UIAlertView的地方,通过 [UIApplication sharedApplication].keyWindow 获取到的窗口是alertView的,因为他的级别最高(霸屏),所以这里,只要alertView消失的时候,你添加到window的view也会一起跟着消失了。

在这里解决办法可以做一个延时,alertView消失0.5秒后,创建view,add view,注意延时的时间要大于0.5秒。

 

-(void)alertView:(UIAlertView*)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {

        [self downloadFileWithUrl:self.currWineClassInfo.fileUrl];

        [self performSelector:@selector(delayView) withObject:nil afterDelay:0.6];

    }

}

-(void)delayView {

UIView *v = [[UIView alloc]initWithFrame:[UIScreen mainScreen].bounds];  

v.backgroundColor = [UIColor redColor];  

[[UIApplication sharedApplication].keyWindow addSubview:v];  

}

转载于:https://www.cnblogs.com/wuxiufang/p/8796018.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值