Is there a way to dismiss an no button UIalertView after some time?

ben picture ben · Nov 16, 2010 · Viewed 11.4k times · Source
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"tittle"
               message:@""
                 delegate:self
              cancelButtonTitle:@""
              otherButtonTitles:nil];
  [alertView show];
  [alertView release];

i want to dimiss the alerview after it's showing for some time,but when the alertview has no button,it doesn't work if i invoked -dismissWithClickedButtonIndex:animated: methodand-performSelector:withObject:afterDelay: is there any other way to dismiss it ? thanks for any ideas!

Answer

ben picture ben · Nov 16, 2010
-(void)xx  {
     [self performSelector:@selector(dismissAlertView:) withObject:alertView afterDelay:2];
}
-(void)dismissAlertView:(UIAlertView *)alertView{
    [alertView dismissWithClickedButtonIndex:0 animated:YES];
}

that's it.i fix it