Instead of push segue how to replace view controller (or remove from navigation stack)?

前端 未结 14 907
眼角桃花
眼角桃花 2020-11-28 01:46

I have a small iPhone app, which uses a navigation controller to display 3 views (here fullscreen):

\"Xcode

14条回答
  •  囚心锁ツ
    2020-11-28 02:33

    Here a quick Swift 4/5 solution by creating a custom seque that replaces the (top stack) viewcontroller with the new one (without animation) :

    class SegueNavigationReplaceTop: UIStoryboardSegue {
    
        override func perform () {
            guard let navigationController = source.navigationController else { return }
            navigationController.popViewController(animated: false)
            navigationController.pushViewController(destination, animated: false)
        }
    }
    

提交回复
热议问题