質問

いくつかの状態が偽の場合、プログラムでセグューをキャンセルする方法を知りたいですか?

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

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 */ 
    }
}
.

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

役に立ちましたか?

解決

セグューの参照: https://developer.apple.com/library/ios/documentation/uikit/reference/uistoryboardsegue_class/reference/reference.html Segueをキャンセルできるパブリックメソッドはありません。

セカウンドが起こった前に、セカンドをやることやそうではなく、それはあなた次第です。

他のヒント

このスレッドをチェックしてください。 UiTableViewCell をタップで実行された条件付きセグメント

基本的にあなたのセグューを直接ボタンにリンクさせる代わりに、ビューコントローラ間に置き、ボタンをコンテンポレーションで関数performseguewithidentifier を呼び出すイビャケーションにリンクします。

ここで別のオプションがあります。 https://stackoverflow.com/a/42161944/4791032

func tableView(_ tableView: UITableView, willSelectRowAt indexPath: IndexPath) で確認できます

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top