如何设置所需用户操作的顺序?

时间:2018-10-31 20:25:59

标签: ios objective-c

我正在尝试先让用户输入信用卡信息,然后同意条款和条件。目前,该应用正在强制用户检查条款和条件,然后输入信用卡信息。有什么更好的方法或更好的方法可以做到这一点?我对目标C不强。

-(void)textFieldDidBeginEditing:(UITextField *)textField{

    if(_agreedToTerms){

        if(!_canceledScan){
    CardIOPaymentViewController *cardV = [[CardIOPaymentViewController alloc]initWithPaymentDelegate:self];
    [cardV setCollectCVV:NO];
        //CardIOPaymentViewController *cardV = [[CardIOPaymentViewController alloc]initWithPaymentDelegate:self];
     [cardV setCollectExpiry:YES];
       // [cardV setCollectPostalCode:YES];
        [self presentViewController:cardV animated:YES completion:nil];
        }
    }else{

    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Error" message:@"Please agree to terms" preferredStyle:UIAlertControllerStyleAlert];
    [alertController addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action)
                                {

                                }]];
    [self presentViewController:alertController animated:YES completion:nil];

    }
}

1 个答案:

答案 0 :(得分:0)

  

什么是更好的方法或更好的方法?

您没有向我们显示足够的代码来提出具体建议,但是通常,如果您希望事情以不同的顺序发生,那么您需要更改代码使这些事情发生的顺序。例如,假设您有一个视图控制器,它要求用户接受条款和条件,而另一个则允许用户输入信用卡信息。这些视图控制器呈现给用户的顺序完全取决于您,并且交换它们应该是一件很简单的事情:您可以在情节提要中重新排列它们,或者交换它们在代码中的位置介绍他们。