Class: ProMotion::TabBarController
- Inherits:
-
UITabBarController
- Object
- UITabBarController
- ProMotion::TabBarController
- Defined in:
- lib/ProMotion/cocoatouch/tab_bar_controller.rb
Class Method Summary collapse
Instance Method Summary collapse
- #find_tab(tab_title) ⇒ Object
- #open_tab(tab) ⇒ Object
- #preferredInterfaceOrientationForPresentation ⇒ Object
-
#shouldAutorotate ⇒ Object
Cocoa touch methods below.
- #supportedInterfaceOrientations ⇒ Object
Class Method Details
.new(*screens) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/ProMotion/cocoatouch/tab_bar_controller.rb', line 4 def self.new(*screens) = 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. = WeakRef.new() if s.respond_to?("tab_bar=") tag_index += 1 s. || s end .viewControllers = view_controllers end |
Instance Method Details
#find_tab(tab_title) ⇒ Object
36 37 38 |
# File 'lib/ProMotion/cocoatouch/tab_bar_controller.rb', line 36 def find_tab(tab_title) viewControllers.find { |vc| vc.tabBarItem.title == tab_title } end |
#open_tab(tab) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/ProMotion/cocoatouch/tab_bar_controller.rb', line 21 def open_tab(tab) if tab.is_a? String selected_tab_vc = find_tab(tab) elsif tab.is_a? Numeric selected_tab_vc = viewControllers[tab] end if selected_tab_vc self.selectedViewController = selected_tab_vc else PM.logger.error "Unable to open tab #{tab.to_s} -- not found." nil end end |
#preferredInterfaceOrientationForPresentation ⇒ Object
50 51 52 |
# File 'lib/ProMotion/cocoatouch/tab_bar_controller.rb', line 50 def preferredInterfaceOrientationForPresentation current_view_controller_try(:preferredInterfaceOrientationForPresentation) end |
#shouldAutorotate ⇒ Object
Cocoa touch methods below
42 43 44 |
# File 'lib/ProMotion/cocoatouch/tab_bar_controller.rb', line 42 def shouldAutorotate current_view_controller_try(:shouldAutorotate) end |
#supportedInterfaceOrientations ⇒ Object
46 47 48 |
# File 'lib/ProMotion/cocoatouch/tab_bar_controller.rb', line 46 def supportedInterfaceOrientations current_view_controller_try(:supportedInterfaceOrientations) end |