천원의 개발

IOS segue를 사용한 화면 전환 본문

iOS&Swift🍎

IOS segue를 사용한 화면 전환

천 원 2022. 3. 21. 20:17

performSegue를 호출하여 새로운 창을 연다

self.performSegue(withIdentifier: "goToResult", sender: self) // "goToReslut" 는 segue이름

넘겨야 할 값이 있을때는 perpare함수를 통해 넘겨준다.

    override func prepare(for segue: UIStoryboardSegue, sender: Any?) { //ResultViewController을 찍을 준비
        if segue.identifier == "goToResult"{
            let destinationVC = segue.destination as! ResultsViewController// ResultsViewController
            destinationVC.bmiValue = calculatorBrain.getBMIValue()
            destinationVC.advice = calculatorBrain.getAdvice()
            destinationVC.color = calculatorBrain.getColor()
        }
    }

'iOS&Swift🍎' 카테고리의 다른 글

IOS Closure 축약순서  (0) 2022.03.23
IOS 네트워킹  (0) 2022.03.22
IOS 버튼 3초 꾹눌렀을때 동작하게  (0) 2022.03.20
IOS/AVAudioPlayer 무음에서 소리 나오게  (0) 2022.03.20
IOS Switch 배경화면 설정  (0) 2022.03.20