Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/115.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 如何在处理程序中指定返回类型_Ios_Ios8 - Fatal编程技术网

Ios 如何在处理程序中指定返回类型

Ios 如何在处理程序中指定返回类型,ios,ios8,Ios,Ios8,我试图使用-(bool)textField shouldClear:(UITextField*)textField,在这里我创建了一个警报,包括两个按钮ok和cancel,因此如果我按下按钮ok,那么-(bool)textField的返回值应该清除:(UITextField*)text字段必须为是 因此,如果我按下按钮cancel,那么-(bool)textField的返回值应该清除:(UITextField*)textField必须是NO 您可以告诉我如何在处理程序中执行此操作吗?您可以使用每

我试图使用
-(bool)textField shouldClear:(UITextField*)textField
,在这里我创建了一个警报,包括两个按钮
ok
cancel
,因此如果我按下按钮
ok
,那么
-(bool)textField的返回值应该清除:(UITextField*)text字段
必须为
因此,如果我按下按钮
cancel
,那么
-(bool)textField的返回值应该清除:(UITextField*)textField
必须是
NO


您可以告诉我如何在处理程序中执行此操作吗?您可以使用每个UIAlertControl的处理程序将全局NSString设置为是或否,然后在“self-presentViewController”之后对其进行评估。处理程序是一个指令块

-(bool)textFieldShouldClear:(UITextField *)textField {

    UIAlertController * blert = [UIAlertController alertControllerWithTitle:@"your alert" message:@"are you sure you want to clear" preferredStyle:UIAlertControllerStyleAlert];

    UIAlertAction * defautact = [UIAlertAction actionWithTitle:@"ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action){}];

    UIAlertAction * defautact1 = [UIAlertAction actionWithTitle:@"cancel" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action){}];

    [blert addAction:defautact];
    [blert addAction: defautact1];
    [self presentViewController:blert animated:YES completion:nil];
}

您可以使用每个UIAlertControl的处理程序将全局NSString设置为Yes或No,然后在“self-presentViewController”之后对其进行求值。处理程序是一个指令块

-(bool)textFieldShouldClear:(UITextField *)textField {

    UIAlertController * blert = [UIAlertController alertControllerWithTitle:@"your alert" message:@"are you sure you want to clear" preferredStyle:UIAlertControllerStyleAlert];

    UIAlertAction * defautact = [UIAlertAction actionWithTitle:@"ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action){}];

    UIAlertAction * defautact1 = [UIAlertAction actionWithTitle:@"cancel" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action){}];

    [blert addAction:defautact];
    [blert addAction: defautact1];
    [self presentViewController:blert animated:YES completion:nil];
}

为什么不在每个UIAlertAction中使用处理程序?为什么不在每个UIAlertAction中使用处理程序?处理程序中存在的代码块未被执行您是否通过NSLog看到字符串?没有?您好,我刚刚找出了问题所在,但我无法解决这一新问题,您可以找到问题的解释,因此最好的方法是直接在处理程序块内管理所有代码处理程序中存在的代码块未被执行您看到NSLog中的字符串了吗?没有?您好,我刚刚找出了问题所在,但我无法解决这个新问题,您可以找到问题的解释,因此最好的方法是直接在处理程序块内管理所有代码