0

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) {

}];

}

代思思
  • 13
  • 5

1 Answers1

0

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


 });
Sh_Khan
  • 86,695
  • 6
  • 38
  • 57
  • thank you for your answer ! but it does not work. Is there any difference in keywindow and keyWindow.rootViewController.view? – 代思思 Dec 24 '17 at 08:54
  • thank you ! it works this time ! but i do not know why. – 代思思 Dec 24 '17 at 09:06
  • 我也有一个问题。当keyWindow窗口上的ImageView的时,成功的提示总是显示在ImageView的的下面。所以我看不到提示,我可以做什么 – 代思思 Dec 24 '17 at 09:10
  • check you constraints also make self.translatesAutoresizingMaskIntoConstraints = NO – Sh_Khan Dec 24 '17 at 09:12