Skip to content

Commit

Permalink
Module first look.
Browse files Browse the repository at this point in the history
  • Loading branch information
jamonholmgren committed Aug 23, 2012
1 parent c5bc649 commit 6a67c9d
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions lib/motion-tab/tab_bar.rb
@@ -0,0 +1,34 @@
module MotionTab
module TabBar
def createTabBarControllerFromData(data)
main_view = MainViewController.alloc.initWithNibName(nil, bundle: nil)
settings_view = SettingsViewController.alloc.initWithNibName(nil, bundle: nil)

mt_tab_controllers = []

data.each do |tab|
tab[:badgeNumber] = 0 unless tab[:badgeNumber]

viewController = tab[:viewController].alloc.init
viewController.tabBarItem = tabBarIcon(tab[:systemIcon], tab[:badgeNumber]) if tab[:systemIcon]

if tab[:navigationController]
controller = UINavigationController.alloc.initWithRootViewController(viewController)
else
controller = viewController
end

mt_tab_controllers << controller
end

tabBarController = UITabBarController.alloc.init
tabBarController.viewControllers = mt_tab_controllers

return tabBarController
end

def tabBarItem(icon, tag = 0)
return UITabBarItem.alloc.initWithTabBarSystemItem(icon, tag: tag)
end
end
end

0 comments on commit 6a67c9d

Please sign in to comment.