clickedButtonAtIndex方法未被调用 [英] clickedButtonAtIndex method is not called

查看:148
本文介绍了clickedButtonAtIndex方法未被调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

.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提前:)

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

推荐答案

委托:nil 是问题所在。传递 self 作为 initWithTitle的委托:message:delegate:cancelButtonTitle:otherButtonTitles:

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

这篇关于clickedButtonAtIndex方法未被调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆