Method: ProMotion::TabBarController.new

Defined in:
lib/ProMotion/cocoatouch/tab_bar_controller.rb

.new(*screens) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/ProMotion/cocoatouch/tab_bar_controller.rb', line 5

def self.new(*screens)
  tab_bar_controller = alloc.init

  screens = screens.flatten.map { |s| s.respond_to?(:new) ? s.new : s } # Initialize any classes

  tag_index = 0
  view_controllers = screens.map do |s|
    s.tabBarItem.tag = tag_index
    s.tab_bar = WeakRef.new(tab_bar_controller) if s.respond_to?("tab_bar=")
    tag_index += 1
    s.navigationController || s
  end

  tab_bar_controller.viewControllers = view_controllers
  name = ""
  tab_bar_controller.delegate = tab_bar_controller
  tab_bar_controller
end