iOS UIAlertController code flow control

我只是一个虾纸丫 提交于 2019-12-11 20:23:56

问题


-(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){
        NSLog(@"tao on YES");
        // click= YES;
        _baba =@"yes";
    }];

    UIAlertAction * defautact1 = [UIAlertAction actionWithTitle:@"cancel" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action){
        NSLog(@"Press on YES");
        // click= NO;
        //field1.text=@"";
        _baba=@"no";
    }];

    [blert addAction:defautact];
    [blert addAction: defautact1];

    [self presentViewController:blert animated:YES completion:nil];

    if([_baba isEqualToString:@"yes"])
    {
        return true;
    }
    else
    {
        return false;
    }
}

When this method is called first the if block is executed and then the UIAlertController is getting executing so that i an getting an undetermined result so can any one solve this problem and make it work in a revere order.

Anyone can you tell me why the view controller is not triggering up last but not first?

来源:https://stackoverflow.com/questions/32938532/ios-uialertcontroller-code-flow-control

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!