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

Version Path
sugarcube-1.5.8 lib/sugarcube-uikit/uiviewcontroller.rb
sugarcube-1.5.7 lib/sugarcube-uikit/uiviewcontroller.rb
sugarcube-1.5.6 lib/sugarcube-uikit/uiviewcontroller.rb
sugarcube-1.5.5 lib/sugarcube-uikit/uiviewcontroller.rb
sugarcube-1.5.4 lib/sugarcube-uikit/uiviewcontroller.rb
sugarcube-1.5.3 lib/sugarcube-uikit/uiviewcontroller.rb
sugarcube-1.5.2 lib/sugarcube-uikit/uiviewcontroller.rb
sugarcube-1.5.1 lib/sugarcube-uikit/uiviewcontroller.rb
sugarcube-1.5.0 lib/sugarcube-uikit/uiviewcontroller.rb
sugarcube-1.4.6 lib/sugarcube-uikit/uiviewcontroller.rb
sugarcube-1.4.5 lib/sugarcube-uikit/uiviewcontroller.rb