내 뷰 컨트롤러에서 특정 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] 삭제
몇 마디 만하겠습니다