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
。