dev._.note

[Swift-UI] 화면전환하기 본문

Dev/SWIFT

[Swift-UI] 화면전환하기

Laena 2024. 1. 11. 06:41

Action Segue를 활용하여 전환하기

@IBAction func tapListButton(_ sender: Any) {
    performSegue(withIdentifier: "showListView", sender: nil)
}

Manual Segue를 활용하여 전환하기

@IBAction func tapListButton(_ sender: Any) {
        //Present
        //WishListViewController를 가져오는 코드
        guard let nextVC = self.storyboard?.instantiateViewController(withIdentifier: "WishListViewController") else { return }
        
        //modalTransitionStyle 지정하는 코드
        self.modalPresentationStyle = .fullScreen
        
        //WishListViewController를 present하는 코드
        self.present(nextVC, animated: true)
        
        //Push
        //WishListViewController를 가져오는 코드
        guard let nextVC = self.storyboard?.instantiateViewController(withIdentifier: "WishListViewController") else { return }
        
        //WishListViewController를 push하는 코드
        self.navigationController?.pushViewController(nextVC, animated: true)
    }

'Dev > SWIFT' 카테고리의 다른 글

[Swift] MVC와 MVVM 장점과 단점  (0) 2024.01.30
[Swift] replacingOccurrences(of:with:)  (0) 2024.01.30
[Swift] lazy란?  (0) 2024.01.10
[Swift] Decodabe, Encodable, Codable  (0) 2024.01.09
[Swift] URLSession  (1) 2024.01.07