0

I am trying to work with a social network framework (CometChat) which is either embedding a Storyboard or Tabbar controller on my UIApplication Window. Now i need a way to dismiss the embedded view when i am done interacting with it. I added a button to the window to call below method to dismiss the embedded

func dismiss() {
 let rootvc = UIApplication.shared.keyWindow?.rootViewController
    for v in (rootvc?.view.subviews)! {
        v.isHidden = true
    }
}

Every view behind the embedded view seems to disappear, but not the embedded view.Screenshot of calling above method

Tried looping through all windows and hiding views in windows, still no luck

let windows = UIApplication.shared.windows
    for window in windows {
        window.rootViewController?.view.isHidden = true
    }

Please Help, i have been on this for about 4 days now.. Thanks in advance.

Shoogarh
  • 9
  • 1
  • 6
  • if you wan to remove all subview then you can try this link https://stackoverflow.com/questions/24312760/how-to-remove-all-subviews-of-a-view-in-swift?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa – AbecedarioPoint May 28 '18 at 09:42
  • Tried the accepted answer, still no luck – Shoogarh May 28 '18 at 09:55

1 Answers1

0

Since you are presenting Embedded ViewController you need to use popviewcontroller and then dismiss it. Kindly refer the below code:

navigationController?.popViewController(animated: true)

dismiss(animated: true, completion: nil)

This should resolve the issue faced by you and you will be able to dismiss the EmbeddedViewController in your App.

CometChat
  • 97
  • 3