Question

Hi I am working with rootViewController. i have task to set runtime rootviewController for createProfile view. and my project is fully navigation base.

But when i get response from server i have to set CreateViewProfile AS RootViewController that i have done as below:

[self.window setRootViewController:myCreateProfile];

But when i click on close button i have to remove above set rootviewController from mainview. for that in my createViewController on my close button action i am doing following:

[self.view removeFromSuperView];

But my problem is that its not removing createViewController which i have set.

Please help me and tell me if i am doing any thing wrong.

Was it helpful?

Solution

[self.view removeFromSuperView] this will from the currentview from it's superView.

From your code it seems you are seeting the ViewCONTROLLER TO THE rootViewController of Window

So in that case you should do as below

Remove The Current ViewController form the Window's RootView Controller and Set which you want

Suppose as you click close BTN the remove CurrentViewController i.e profileView.

[self.window setRootViewController:nil];

and then set desired ViewController which you want.

[self.window setRootViewController:createViewController];

createViewController instance of ViewController which you want to show on closing the profileView

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top