提问人:代思思 提问时间:12/24/2017 更新时间:12/24/2017 访问量:134
如何在UIAlertController之后在键窗口中显示视图
How to show view on the keywindow after UIAlertController
问:
我想做一个保存图片功能,成功后弹出提示。当我按下图片弹出alertController,保存成功时没有看到按键窗口上显示的提示框,这是怎么回事?
//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) {
}];
}
答:
0赞
Shehata Gamal
12/24/2017
#1
试试这个
// 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];
});
评论
0赞
代思思
12/24/2017
谢谢你的回答!但它不起作用。keywindow 和 keyWindow.rootViewController.view 有什么区别吗?
0赞
代思思
12/24/2017
谢谢 ! 这次成功了!但我不知道为什么。
0赞
代思思
12/24/2017
我也有一个问题。当keyWindow窗口上的ImageView的时,成功的提示总是显示在ImageView的下面。所以我看不到提示,我可以做什么
0赞
Shehata Gamal
12/24/2017
检查约束是否也使 self.translatesAutoresizingMaskIntoConstraints = NO
评论