//一个可以自动关闭的Alert窗口
UIAlertView*alert = [[UIAlertView alloc] initWithTitle:nil
message:[@"一个可以自动关闭的Alert窗口"
delegate:nil
cancelButtonTitle:nil//NSLocalizedString(@"OK",@"OK") //取消任何按钮
otherButtonTitles:nil];
//[alertsetBounds:CGRectMake(alert.bounds.origin.x, alert.bounds.origin.y,alert.bounds.size.width,alert.bounds.size.height+30.0)];
[alertshow];
UIActivityIndicatorView*indicator = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
//Adjust the indicator so it is up a few pixels from the bottom ofthe alert
indicator.center= CGPointMake(alert.bounds.size.width/2, alert.bounds.size.height-40.0);
[indicatorstartAnimating];
[alertinsertSubview:indicator atIndex:0];
[indicatorrelease];
[NSTimerscheduledTimerWithTimeInterval:3.0f
target:self
selector:@selector(dismissAlert:)
userInfo:[NSDictionarydictionaryWithObjectsAndKeys:alert, @"alert", @"testing ", @"key",nil] //如果不用传递参数,那么可以将此项设置为nil.
repeats:NO];
NSLog(@"releasealert");
[alertrelease];
-(void)dismissAlert:(NSTimer *)timer{
NSLog(@"releasetimer");
NSLog([[timeruserInfo] objectForKey:@"key"]);
UIAlertView*alert = [[timer userInfo] objectForKey:@"alert"];
[alertdismissWithClickedButtonIndex:0 animated:YES];
}