Sha256: 72113855a1879ebe4d99123bc686494aac0663f1795a4542b668eb6076ea15e6

Contents?: true

Size: 767 Bytes

Versions: 2

Compression:

Stored size: 767 Bytes

Contents

module MotionPrime
  class TabBarController < UITabBarController
    
    def self.new(screens)
      controller = alloc.init

      view_controllers = []

      screens.each_with_index do |screen, index|
        screen.tabBarItem.tag = index
        screen.send(:on_screen_load) if screen.respond_to?(:on_screen_load)
        screen.wrap_in_navigation if screen.respond_to?(:wrap_in_navigation)
        screen.tab_bar = controller if screen.respond_to?(:tab_bar=)
        view_controllers << screen.main_controller
      end

      controller.viewControllers = view_controllers
      controller
    end
    
    def open_tab(tab)
      controller = viewControllers[tab]
      if controller
        self.selectedViewController = controller
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
motion-prime-0.4.0 motion-prime/support/tab_bar_controller.rb
motion-prime-0.3.3 motion-prime/support/tab_bar_controller.rb