clickedButtonAtIndex方法不被调用

当用户点击UIAlertView上的button时, clickedButtonAtIndex方法应该被调用,但是,它不会:

.h我已经调用了UIAlertView协议:

 @interface RechercherViewController : UIViewController<UIAlertViewDelegate> { //code } 

并在.m文件中我有这样的:

 -(void)requestFailed:(ASIHTTPRequest *)request { //quand il y aura un échec lors de l'envoie de la requête UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"TopStation" message :@"Your internet connexion is down" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert show]; [alert release]; } - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{ if (buttonIndex == 0) { NSLog(@"buttonIndex 0"); } else if(buttonIndex == 1) { NSLog(@"buttonIndex 1"); } } 

没有在日志文件中显示,请提前帮助,thx 🙂

delegate:nil是问题。 将self作为委托传递给initWithTitle:message:delegate:cancelButtonTitle:otherButtonTitles:

您作为委托parameter passingnil 。 通过self