SEGUE를 프로그래밍 방식으로 취소하고 동일한보기에 남아있는 방법

StackOverflow https://stackoverflow.com//questions/9661190

  •  12-12-2019
  •  | 
  •  

문제

일부 조건이 거짓 일 때 프로그램에서 세그 슈를 어떻게 취소합니까?

아래의 코드 스 니펫은 다음과 같습니다.

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

아무도 나를 안내 할 수 있다면 그것은 큰 도움이 될 것입니다.

도움이 되었습니까?

해결책

SEGUE에 대한 참조 : HTTPS ://developer.apple.com/library/ios/documentation/uikit/reference/uistoryboardsegue_class/reference/reference.html 세그 슈를 취소 할 수있는 공개 메서드가 없습니다.

SeGue가 시작되기 전에 세그투가 시작되기 전에 조건을 기반으로하는 것으로 결정하는 것이 더 쉬울 것입니다.

다른 팁

이 글꼴을 확인하십시오. uitiviewViewCell에서 탭에서 수행 된 조건부 세그리트

기본적으로 SeGue를 버튼에 직접 연결하는 대신 뷰 컨트롤러간에 넣고 단추를 조건부로 연결하는 iBACTION에 단추를 링크하는 기능을 수행합니다.

여기에 또 다른 옵션이 있습니다 : https://stackoverflow.com/a/42161944/4791032

func tableView(_ tableView: UITableView, willSelectRowAt indexPath: IndexPath) 에서 확인할 수 있습니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top