Class: MotionPrime::TabBarController

Inherits:
UITabBarController
  • Object
show all
Defined in:
motion-prime/screens/controllers/tab_bar_controller.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.new(screens, global_options = {}) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'motion-prime/screens/controllers/tab_bar_controller.rb', line 3

def self.new(screens, global_options = {})
  controller = alloc.init

  view_controllers = []

  screens.each_with_index do |options, index|
    if options.is_a?(Hash)
      screen = init_screen_with_options(global_options.deep_merge(options), tag: index)
    else
      screen = options
      screen.tabBarItem.tag = index
    end

    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.weak_ref if screen.respond_to?(:tab_bar=)
    view_controllers << screen.main_controller.strong_ref
  end

  controller.viewControllers = view_controllers
  controller
end

Instance Method Details

#deallocObject



34
35
36
37
38
# File 'motion-prime/screens/controllers/tab_bar_controller.rb', line 34

def dealloc
  Prime.logger.dealloc_message :tab_bar, self
  clear_instance_variables
  super
end

#open_tab(tab) ⇒ Object



26
27
28
29
30
31
32
# File 'motion-prime/screens/controllers/tab_bar_controller.rb', line 26

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