创建没有按钮的UIAlertView
默认的,UIAlertView都有一个或者多个按钮,如果你想创建没有按钮的UIAlertView,可以使用以下的方法:
-
-
UIAlertView *alert;
-
alert = [[[UIAlertView alloc] initWithTitle:@"Configuring Preferences\nPlease Wait…"
-
message:nil delegate:self cancelButtonTitle:nil otherButtonTitles: nil] autorelease];
-
-
[alert show];
-
上面的标题可能有些靠上,可以用过给标题增加回车的方式,使标题居中:
-
-
UIAlertView *alert;
-
alert = [[[UIAlertView alloc] initWithTitle:@"\n\nConfiguring Preferences\nPlease Wait…"
-
message:nil delegate:self cancelButtonTitle:nil otherButtonTitles: nil] autorelease];
-
-
[alert show];
-
如果你还想给UIAlertView添加一个等待提示符,则可以这么做:
-
-
UIAlertView *alert;
-
alert = [[[UIAlertView alloc] initWithTitle:@"Configuring Preferences\nPlease Wait…" message:nil delegate:self cancelButtonTitle:nil otherButtonTitles: nil] autorelease];
-
[alert show];
-
-
UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
-
-
// Adjust the indicator so it is up a few pixels from the bottom of the alert
-
indicator.center = CGPointMake(alert.bounds.size.width / 2, alert.bounds.size.height – 50);
-
[indicator startAnimating];
-
[alert addSubview:indicator];
-
[indicator release];
-
解除UIAlertView的显示
设置定时器[NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(performDismiss) userInfo:nil repeats:NO];
调用如下方法:
- (void)performDismiss {
[baseAlert dismissWithClickedButtonIndex:0 animated:NO];
}
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步