본문 바로가기

개발 & IT/백엔드

[Swift] hierarchy 문제

반응형

AController(UINavigationController). topViewController = BController(UIViewController)

로 호출한 뷰컨트롤러를 다시 호출할 경우 계층 문제 발생하며 컨트롤러가 로드되지 않는 문제 발생.

 

뷰 컨트롤러 호출하기 전에 현재 호출된 뷰 컨트롤러 체크 후 

동일한 뷰컨트롤러이면 dismiss 하도록 수정

let pvc = self.presentedViewController

//현재 컨트롤러가 UINavigationController 니?
if let nc = pvc as? UINavigationController, nc.viewControllers.count > 0 {
    //고렇다면 현재컨트롤러의 topViewController가 BController 니?
    if((nc.topViewController?.isKind(of: BController.self)) != nil) {
        // 응 dismiss
        nc.dismiss(animated: false, completion: nil)
    }

}

 

 

 

 

 

 

반응형

'개발 & IT > 백엔드' 카테고리의 다른 글

[PHP] XMLWriter  (0) 2022.09.19
[Swift] EXC_BREAKPOINT (SIGTRAP)  (2) 2022.09.08
[laravel5.5] 302 redirect status code  (2) 2022.09.06
[laravel 5.5/QueryBuilder] SubQuery  (1) 2022.08.30
[Gmail/smtp] 보안 사항 변경  (2) 2022.08.30