clickedButtonAtIndex 方法未被调用

2024-05-05

当用户点击按钮时UIAlertView the clickedButtonAtIndex应该调用方法,但是,它没有:

in the .h我已经打电话给UIAlertView协议 :

@interface RechercherViewController : UIViewController<UIAlertViewDelegate>  {

//code
}

and in .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");
    }
}

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


delegate:nil是问题所在。经过self作为代表initWithTitle:message:delegate:cancelButtonTitle:otherButtonTitles:.

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

clickedButtonAtIndex 方法未被调用 的相关文章

随机推荐