Closed DougPuchalski closed 11 years ago
Not to call removeFromParentViewController
; pop
is the complement to push
, so it should re-assign the list of view controllers, removing the last one on the stack (makes most sense with the UINavigationController
)
I may be a bit confused. Are we both talking about this?
sugarcube/lib/sugarcube/uiviewcontroller.rb
class UIViewController
def push(view_controller)
self.addChildViewController(view_controller)
view_controller.didMoveToParentViewController(self)
self
end
...
end
Right, so push
accepts the child controller as an argument, and pop
would remove that same child. Maybe I misunderstood what you are recommending, but it sounded like
def pop
removeFromParentViewController
end
Did I misunderstand?
Yes that's what I was suggesting, I wasn't sure I understood your first response. Seems like if you have a push you should have a pop.
I thought about it and I might add it, but it would look like this:
def pop
to_pop = self.childViewControllers[-1]
to_pop.removeFromParentViewController
end
That way it would work like UINavigationController
's pop method (and Array
for that matter!)
Yes that's totally right, my mistake. Or even if it takes an optional parameter for the controller. In general I like the idea where if you have a push you should have a pop.
@colinta, let me know if you want me to toss this into the code/write tests for it.
Sure if you have a sec! I'm busy just trying to keep up with email this week :-)
On Mar 28, 2013, at 5:05 PM, Gant Laborde notifications@github.com wrote:
colinta, let me know if you want me to toss this into the code/write tests for it.
\ Reply to this email directly or view it on GitHub.
This issue should be ready to be closed :)
Thanks again, @GantMan!
Should there be a UIViewController.pop method to call removeFromParentViewController?