랭귀지/SWIFT
[iOS : Swift] Segue 코드상으로 연결하는 방법
유키공
2018. 2. 6. 13:19
코드로 정의하기
스토리보드를 이용하지 않고 코드상으로 연결하는 방법입니다.@IBAction private func playBtn(_ sender: UIButton) {
let vc = self.storyboard?.instantiateViewController
(withIdentifier: "Resultsidentifer") as! ResultsViewController
vc.userChoice = getUserShape(sender)
present(vc, animated: true, completion: nil)
}
withIdentifier의 "Resultsidentifer" 부분은 두 번째 view controller의 identifer이고 그 뒤 ResultsViewController는 class이름입니다.