Sha256: 75b6550645891dcc1bf79048659cd65c6eb6d21f431ae0eb8cab1266d4558c30

Contents?: true

Size: 998 Bytes

Versions: 6

Compression:

Stored size: 998 Bytes

Contents

class UIViewController

  def push(view_controller)
    self.addChildViewController(view_controller)
    view_controller.didMoveToParentViewController(self)
    self
  end

  # `alias << push` won't work. it doesn't "respect" subclasses overriding the
  # `push` method.
  def <<(view_controller)
    push view_controller
  end

end


class UINavigationController

  def push(view_controller)
    self.pushViewController(view_controller, animated: true)
    self
  end

  def pop(to_view=nil)
    if to_view == :root
      self.popToRootViewControllerAnimated(true)
    elsif to_view
      self.popToViewController(to_view, 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

6 entries across 6 versions & 1 rubygems

Version Path
sugarcube-0.20.1 lib/sugarcube/uiviewcontroller.rb
sugarcube-0.20.0 lib/sugarcube/uiviewcontroller.rb
sugarcube-0.19.5 lib/sugarcube/uiviewcontroller.rb
sugarcube-0.19.4 lib/sugarcube/uiviewcontroller.rb
sugarcube-0.19.2 lib/sugarcube/uiviewcontroller.rb
sugarcube-0.19.0 lib/sugarcube/uiviewcontroller.rb