Replace the viewcontroller without it appearing behind it

64 Views Asked by At

My issue occurs when changing the VC, the old VC continues to appear in the background (see screen capture). How can I fix it?

Thank you for your help.

2

There are 2 best solutions below

2
Asif Mujtaba On BEST ANSWER

The sheet presentation style appears as a card. To make it fullscreen use this.

let vc = UIViewController()
vc.modalPresentationStyle = .fullScreen //or .overFullScreen for transparency
self.present(vc, animated: true, completion: nil)
0
mattom On

If VC is to disappear, try to get rid of its reference - call the destructor - deinit, and then VC will be destroyed by ARC

Helpful link: Swift deinitialization and ARC