创建没有按钮的UIAlertView
by Elton on 二.11, 2010, under iPhone
默认的,UIAlertView都有一个或者多个按钮,如果你想创建没有按钮的UIAlertView,可以使用以下的方法:
1 2 3 4 5 6 7 8 | UIAlertView *alert; ... alert = [[[UIAlertView alloc] initWithTitle:@"Configuring PreferencesnPlease Wait..." message:nil delegate:self cancelButtonTitle:nil otherButtonTitles: nil] autorelease]; [alert show]; |

上面的标题可能有些靠上,可以用过给标题增加回车的方式,使标题居中:
1 2 3 4 5 6 7 8 | UIAlertView *alert; ... alert = [[[UIAlertView alloc] initWithTitle:@"nnConfiguring PreferencesnPlease Wait..." message:nil delegate:self cancelButtonTitle:nil otherButtonTitles: nil] autorelease]; [alert show]; |

如果你还想给UIAlertView添加一个等待提示符,则可以这么做:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | UIAlertView *alert; ... alert = [[[UIAlertView alloc] initWithTitle:@"Configuring PreferencesnPlease 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的显示
因为这个AlertView没有按钮,所以就不能通过点击按钮将这个提示框去掉。可以通过程序的方式,将这个窗口关掉。
[alert dismissWithClickedButtonIndex:0 animated:YES];



六月 18th, 2010 on 00:06
indicator.center = CGPointMake(alert.bounds.size.width / 2, alert.bounds.size.height – 50);
试过后发现这句没法居中
五月 17th, 2011 on 13:08
太好了,这个我现在就用的上!太感谢了!!!!
五月 17th, 2011 on 15:13
大哥,建议你以后把写好的文章地址发到微博上去,让更多的人看到,找到你的博客算是我今天最幸运的事情了!!!