本文介绍了UIAlertview 没有正确关闭?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 UIAlertview
和 viewdidload()
中的一个活动指示器.但我试图在延迟后但在删除 后从超级视图中删除它UIAlertview
使用以下代码我无法在应用程序中执行任何操作.就像一个新的透明层仍在我的视图上方运行.
I am using a UIAlertview
and inside that one activity indicator in viewdidload()
.But i tried to remove its from superview after a delay but after removing UIAlertview
using following code i am not able to do anything in app.Is like a new transparent layer is still running above my view.
代码
-(void)startAlertActivity
{
_alertView = [[UIAlertView alloc] initWithTitle:@"Loading "
message:@"\n"
delegate:self
cancelButtonTitle:nil
otherButtonTitles:nil];
spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
spinner.center = CGPointMake(139.5, 75.5); // .5 so it doesn't blur
[_alertView addSubview:spinner];
[spinner startAnimating];
[_alertView show];
[_alertView performSelector:@selector(stopAlertActivity) withObject:self afterDelay:5.0];
}
-(void)stopAlertActivity
{ [spinner stopAnimating];
[_alertView dismissWithClickedButtonIndex:0 animated:YES];
}
ITS 看起来像一个仍在屏幕上运行的透明层,我该如何关闭它?
ITS look like a transparent layer still running on screen,How can i close that?
示例图片....
对我来说,警报现在不在屏幕上,但背景是浅蓝色
崩溃报告
[UIAlertView stopAlertActivity]: unrecognized selector sent to instance 0x9ab5eb0
2013-08-02 12:20:43.822 AssamKart[5719:12203] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIAlertView stopAlertActivity]: unrecognized selector sent to instance 0x9ab5eb0'
*** First throw call stack:
推荐答案
你真的应该使用 dispatch_after
you should really be using dispatch_after
_alertView = [[UIAlertView alloc] initWithTitle:@"Loading "
message:@"\n"
delegate:self
cancelButtonTitle:nil
otherButtonTitles:nil];
spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
spinner.center = CGPointMake(139.5, 75.5); // .5 so it doesn't blur
[_alertView addSubview:spinner];
[spinner startAnimating];
[_alertView show];
double delayInSeconds = 5.0;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
[spinner stopAnimating];
[_alertView dismissWithClickedButtonIndex:0 animated:YES];
});
这篇关于UIAlertview 没有正确关闭?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!