Sha256: 93182022062e9057c1e7f31eac20764c7e26f9d7c942c8a918d2a9366d7cd7a3
Contents?: true
Size: 1.04 KB
Versions: 71
Compression:
Stored size: 1.04 KB
Contents
class UIViewController def push(view_controller) self.addChildViewController(view_controller) self end # `alias << push` won't work. it doesn't "respect" subclasses overriding the # `push` method. def <<(view_controller) push view_controller end def pop to_pop = self.childViewControllers[-1] if to_pop to_pop.removeFromParentViewController end end end class UINavigationController def push(view_controller) self.pushViewController(view_controller, animated: true) self end def pop(to_vc=nil) if to_vc == :root self.popToRootViewControllerAnimated(true) elsif to_vc self.popToViewController(to_vc, animated: true) else self.popViewControllerAnimated(true) end end end class UITabBarController def push(view_controller) view_controllers = [] if self.viewControllers view_controllers += self.viewControllers end view_controllers << view_controller self.setViewControllers(view_controllers, animated: true) self end end
Version data entries
71 entries across 71 versions & 1 rubygems