Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UIAlertview赢得';t测井结果_Ios_Objective C_Uialertview_Uialertviewdelegate - Fatal编程技术网

Ios UIAlertview赢得';t测井结果

Ios UIAlertview赢得';t测井结果,ios,objective-c,uialertview,uialertviewdelegate,Ios,Objective C,Uialertview,Uialertviewdelegate,如果用户在我的alertView上按了OK,我想记录,但它什么也没做。。。这是我的支票: - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { if (buttonIndex == 0) { NSLog(@"user pressed OK"); } } 它也在我的@界面中: @interface FirstViewController : UIViewContro

如果用户在我的
alertView
上按了OK,我想记录,但它什么也没做。。。这是我的支票:

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
    if (buttonIndex == 0) { NSLog(@"user pressed OK"); }
}
它也在我的
@界面中

@interface FirstViewController : UIViewController<UIWebViewDelegate, UIAlertViewDelegate>
有人看到问题了吗?我尝试在
if按钮索引
之外执行
NSLog
,但也不会被记录


谢谢

将您的代表指定为self而不是nil,使用以下命令将您的代表指定为self而不是nil:

UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Oeps..."
                                        message:@"This is just a random message."
                                        delegate:self
                                        cancelButtonTitle:@"OK"
                                        otherButtonTitles:nil];
[alertView show];
使用以下命令:

UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Oeps..."
                                        message:@"This is just a random message."
                                        delegate:self
                                        cancelButtonTitle:@"OK"
                                        otherButtonTitles:nil];
[alertView show];

检查您的委托您将委托传递给了nil。把它传给self,这就是发生的事情

像这样

UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Oeps..."
                                            message:@"This is just a random message."
                                            delegate:self
                                            cancelButtonTitle:@"OK"
                                            otherButtonTitles:nil];
[alertView show];

检查您的委托您将委托传递给了nil。把它传给self,这就是发生的事情

像这样

UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Oeps..."
                                            message:@"This is just a random message."
                                            delegate:self
                                            cancelButtonTitle:@"OK"
                                            otherButtonTitles:nil];
[alertView show];