如何在UIAlertController之后在keywindow上显示视图

时间:2017-12-24 08:28:21

标签: ios uialertcontroller keywindow

我想在弹出提示成功之后做一个保存图像功能。当我按下图片弹出alertController时,保存成功没有看到keywindow上显示的提示框,发生了什么事?

 //show the tip of suceess
-(void)show{
UIWindow * window =[UIApplication sharedApplication].keyWindow;
[window addSubview:self];
[self mas_makeConstraints:^(MASConstraintMaker *make) {
    make.top.equalTo(window.mas_top);
    make.leading.equalTo(window.mas_leading);
    make.trailing.equalTo(window.mas_trailing);
    make.bottom.equalTo(window.mas_bottom);
}];
[self layoutIfNeeded];


self.alpha = 0;
[UIView animateWithDuration:.2 animations:^{
    self.alpha = 1;
}];

_alertView.transform = CGAffineTransformMakeScale(0.1, 0.1);
[UIView animateWithDuration:0.3 delay:0.0 usingSpringWithDamping:0.7 initialSpringVelocity:1 options:UIViewAnimationOptionCurveEaseOut animations:^{
    _alertView.alpha=1.0;
    _alertView.transform = CGAffineTransformIdentity;
} completion:^(BOOL finished) {

}];

}

1 个答案:

答案 0 :(得分:0)

试试这个

 // Delay execution of my block for 10 seconds.
 dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 10 * NSEC_PER_SEC),     dispatch_get_main_queue(), ^{

         UIView * windowView =[UIApplication sharedApplication].keyWindow.rootViewController.view;
        [windowView addSubview:self];


 });