2010-08-05 7 views
0

J'aime:Je ne peux pas fermer la UIAlertView

**//some methods of myButton inheried from UIButton** 

-(void)timerFireMethod:(NSTimer*)theTimer 
{ 
     UIAlertView *alert = [ [ UIAlertView alloc ] initWithTitle:@"hello" message:@"alerts" delegate:self cancelButtonTitle:@"cancel" otherButtonTitles:nil ]; 
     [alert show]; 
} 

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event 
{ 
    timer = [NSTimer scheduledTimerWithTimeInterval:5 target:self selector:@selector(timerFireMethod:) userInfo:nil repeats:NO]; 
} 

-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event 
{ 
    [timer invalidate]; 
} 

1) Je touche le mais jusqu'à montrer la UIAlertView, puis je vais cliquer sur le bouton d'annulation de la UIAlertView, mais le UIAlertView ne ferme pas.

2) Si je retourne en [timer invalidate];//[timer invalidate];

et aime comme je l'ai fait dans le code ci-dessus, la UIAlertView peut fermer.

Pourquoi?

+0

Veuillez formater votre code. –

+0

Je ne comprends pas votre question. Pouvez-vous le reformuler? – vodkhang

+0

J'ai résolu ma question en changeant "répète: NON" à "répète: OUI". – lqf

Répondre

0

Vous ne libérez pas la vue d'alerte.

UIAlertView *alert = [ [ UIAlertView alloc ] initWithTitle:@"hello" message:@"alerts" delegate:self cancelButtonTitle:@"cancel" otherButtonTitles:nil ]; 
    [alert show]; 
    [alert release]; // <-- important 
Questions connexes