按照窗口将以秒后自动关闭

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil
                                                    message:[@"Alert"
                                                   delegate:nil
                                          cancelButtonTitle:nil //NSLocalizedString(@"OK", @"OK")   //
                                          otherButtonTitles:nil];
    //[alert setBounds:CGRectMake(alert.bounds.origin.x, alert.bounds.origin.y, alert.bounds.size.width, alert.bounds.size.height+30.0)];
    [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-40.0);
    [indicator startAnimating];
    [alert insertSubview:indicator atIndex:0];
    [indicator release];

    [NSTimer scheduledTimerWithTimeInterval:3.0f
                                     target:self
                                   selector:@selector(dismissAlert:)
                                   userInfo:[NSDictionary dictionaryWithObjectsAndKeys:alert, @"alert", @"testing ", @"key" ,nil]  //nil.
                                    repeats:NO];

    NSLog(@"release alert");
    [alert release];

-(void) dismissAlert:(NSTimer *)timer{

    NSLog(@"release timer");
    NSLog([[timer userInfo]  objectForKey:@"key"]);

    UIAlertView *alert = [[timer userInfo]  objectForKey:@"alert"];
    [alert dismissWithClickedButtonIndex:0 animated:YES];

}

//
[timer invalidate];
timer = nil;
//该片段来自于http://outofmemory.cn

[Ctrl+A 全选
注:如需引入外部Js需刷新才会行]

发表评论

电子邮件地址不会被公开。 必填项已用*标注

网站地图xml地图