Swift의 특정 조건에서 코드를 사용하여 한 뷰 컨트롤러에서 다른 뷰 컨트롤러로 이동하는 방법은 무엇입니까?

샤함 캄팔라

내 뷰 컨트롤러에서 특정 if 조건에 따라 자동으로 다음 뷰 컨트롤러로 이동하고 싶습니다. 이 코드를 시도했습니다. 하지만 작동하지 않습니다. 도와주세요.

if rightCounter == 5 {

        var Level2 = self.storyboard?.instantiateViewControllerWithIdentifier("Level2") as? ViewController
        self.presentViewController(Level2!, animated: true, completion: nil)
    }

}
칸 데비 자야
    if condition == true {
        //use either VC Name associate or the Storyboard restoration id
        //replace this with yours 
        if let Level2 = self.storyboard!.instantiateViewControllerWithIdentifier("MainVC") as? UIViewController
        {
            self.presentViewController(Level2, animated: true, completion: nil)
        }


    }

문제는 다른 VC를 ViewController로 캐스팅하려고 시도하는 데 있다고 생각합니다.

스토리 보드 ID가 있는지 확인하고 대소 문자를 UIViewController에 광범위하게 입력하거나 특정 VC를 구체적으로 입력 할 수 있습니다.

여기에 이미지 설명 입력

도움이 되었기를 바랍니다.

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

TOP 리스트

뜨겁다태그

보관