开发者

clickedButtonAtIndex method is not called

开发者 https://www.devze.com 2023-03-06 15:48 出处:网络
when the userclick on a button on the UIAlertView the clickedButtonAtIndex method is supposed to be called, however, it doesn\'t :

when the user click on a button on the UIAlertView the clickedButtonAtIndex method is supposed to be called, however, it doesn't :

in the .h i have called the UIAlertView protocol :

@interface RechercherViewController : UIViewController<UIAlertViewDelegate>  {

//code
}

and in 开发者_StackOverflow.m file i have this :

-(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");
    }
}

nothing is shown in the log file, please help, thx in advance :)


delegate:nil is the problem. Pass self as the delegate to initWithTitle:message:delegate:cancelButtonTitle:otherButtonTitles:.


You're passing nil as the delegate argument. Pass self instead.

0

精彩评论

暂无评论...
验证码 换一张
取 消