[iOS] 모달 닫기
모달을 열면 모달을 닫고 싶습니까? 라는 기사입니다.
버전
Swift 5.3
Xcode 12.1
모달 닫기
모달을 닫으려면 UIViewController의 인스턴스 메서드인 dismiss를 사용합니다.
구현
파일 추가
먼저 모달에 대한 ViewController를 추가합니다.

New File...에서

코코아 터치 클래스를 선택하고 다음을 클릭하십시오.

이번에는 ModalViewController라는 이름으로 파일을 만듭니다.
파일과 뷰 연결
모달에 대한 뷰와 파일을 연결합니다.

닫기 위한 버튼 배치
Modal용 뷰에 버튼을 배치합니다.

모달을 닫는 함수 작성
모달을 닫는 함수를 작성합니다.
ModalViewController.swiftimport UIKit
class ModalViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
@IBAction func closeModal() {
self.dismiss(animated: true, completion: nil)
}
}
버튼과 함수를 연결
버튼과 함수를 연결합니다.

완성
완성이다! 했어! ! !

참고문헌
모달을 닫으려면 UIViewController의 인스턴스 메서드인 dismiss를 사용합니다.
구현
파일 추가
먼저 모달에 대한 ViewController를 추가합니다.

New File...에서

코코아 터치 클래스를 선택하고 다음을 클릭하십시오.

이번에는 ModalViewController라는 이름으로 파일을 만듭니다.
파일과 뷰 연결
모달에 대한 뷰와 파일을 연결합니다.

닫기 위한 버튼 배치
Modal용 뷰에 버튼을 배치합니다.

모달을 닫는 함수 작성
모달을 닫는 함수를 작성합니다.
ModalViewController.swiftimport UIKit
class ModalViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
@IBAction func closeModal() {
self.dismiss(animated: true, completion: nil)
}
}
버튼과 함수를 연결
버튼과 함수를 연결합니다.

완성
완성이다! 했어! ! !

참고문헌
import UIKit
class ModalViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
@IBAction func closeModal() {
self.dismiss(animated: true, completion: nil)
}
}
Reference
이 문제에 관하여([iOS] 모달 닫기), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/tanaka-tt/items/bd1ffe495a0a0cf608d1텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)