3

条件が偽の場合、プログラムでセグエをキャンセルする方法を知りたいですか?

以下は私のコードスニペットです:

if ([segue.identifier isEqualToString:@"Information Segue"])
{   
    NSFetchRequest *request = [[NSFetchRequest alloc] init];
    NSEntityDescription *entity = [NSEntityDescription entityForName:@"Login" inManagedObjectContext:self.managedObjectContext];
    NSPredicate *predicate = [NSPredicate predicateWithFormat:@" ANY userid==%@ AND password==%@",_loginTextfield.text, _passwordTextField.text];
    [request setEntity:entity];
    [request setPredicate:predicate];
    NSError *anyError=Nil;
    NSArray *fetchedObjects = [self.managedObjectContext executeFetchRequest:request error:&anyError];
    if ([fetchedObjects count] )
    {
        useridentered = _loginTextfield.text;
        passwordentered = _passwordTextField.text;

        InformationTVC *informationTVC = segue.destinationViewController;
        informationTVC.managedObjectContext = self.managedObjectContext;             
    }
    else
    {
       /*  want to put my cancel the segue and remain in the login view */ 
    }
}

誰かが私を導くことができれば、それは大きな助けになるでしょう。

4

3 に答える 3

2

このスレッドをチェックしてください: UITableViewCell のタップで実行される条件付きセグエ

基本的に、セグエをボタンに直接リンクする代わりに、それをビュー コントローラーの間に配置し、条件付きで関数 performSegueWithIdentifier を呼び出す IBAction にボタンをリンクします。

于 2012-03-22T03:27:58.503 に答える
0

セグエの参照: https://developer.apple.com/library/ios/DOCUMENTATION/UIKit/Reference/UIStoryboardSegue_Class/Reference/Reference.htmlセグエ をキャンセルできるパブリック メソッドはありません。

セグエが発生し始める前に、条件に基づいてセグエを行うかどうかを決定する方が簡単だと思いますが、それはあなた次第です。

于 2012-03-12T03:13:43.167 に答える