Search code examples
iosobjective-cuialertviewdismiss

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


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!


Solution

  • -(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