问题
-(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