ECSlidingViewController / ECSlidingViewController

Customizable sliding view controller container.
MIT License
4.32k stars 817 forks source link

Need To Be Able to Remove Top View Controller; Set to nil #203

Closed davidbitton closed 11 years ago

davidbitton commented 11 years ago

I setup a scenario that after a user logs into my app, I then set the top view controller to my split view controller. When a user clicks Logout in the under left menu, I need to, essentially, pop the split view controller and return to just my root controller. Here is my storyboard:

sedonafsu xcworkspace__main storyboard

I tried passing nil to the topViewController however this had expected results; an exception. How shall I handle this scenario?

enriquez commented 11 years ago

The sliding view controller's container view is expected to be empty.

I would move all the stuff you have from the container view into a new view controller. Then the state of your app can decide on which topViewController to show.

davidbitton commented 11 years ago

OK, I moved some things around. Now, the colored background is a ViewController of its own of which I set as the top view controller in my viewWillAppear. When the user logs in, I change the top view to my split view controller. Logout now works because I can set the top view controller back to the colored background. However, is there any way to animate that transition? Thanks.

sedonafsu xcworkspace__main storyboard

jeffarena commented 11 years ago

@davidbitton you're not going to be able to simply animate the set of the topViewController property during your logout. i'd probably make your colored view controller the topViewController at all times, and then conditionally add the split view controller to it as a child view controller when a user is logged in. you can then animate the adding/removing of the split view controller's view as a child, as needed. how you handle that animation will depend greatly on the desired visual effect.

davidbitton commented 11 years ago

@jeffarena I had that setup several iterations ago. I'll leave it like this for the time being while I build up the app. I'll come back for polish later. Thanks!