0

当用户单击应该调用UIAlertView该方法的按钮时,它不会: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");
    }
}

日志文件中没有显示任何内容,请帮助,提前谢谢:)

4

2 回答 2

4

delegate:nil是问题所在。self作为代表传递给initWithTitle:message:delegate:cancelButtonTitle:otherButtonTitles:.

于 2011-05-18T16:10:25.460 回答
2

nil作为委托参数传递。self而是通过。

于 2011-05-18T16:09:59.823 回答