How to show view on the keywindow after UIAlertController

141 Views Asked by At

I want to do a save image function, after the success of the pop-up tips. When I press the picture pop-up alertController, save the success did not see the prompt box displayed on the keywindow, what is going on ?

 //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

There are 1 best solutions below

4
On

Try this

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


 });