Skip to content

Commit

Permalink
…with class methods…
Browse files Browse the repository at this point in the history
  • Loading branch information
jamonholmgren committed Aug 23, 2012
1 parent 8983a4f commit eda1dde
Showing 1 changed file with 23 additions and 21 deletions.
44 changes: 23 additions & 21 deletions lib/motion-tab/tab_bar.rb
Original file line number Diff line number Diff line change
@@ -1,31 +1,33 @@
module MotionTab
class TabBar
def createTabBarControllerFromData(data)
mt_tab_controllers = []
class << self
def createTabBarControllerFromData(data)
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
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
mt_tab_controllers << controller
end

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

return tabBarController
end
return tabBarController
end

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

0 comments on commit eda1dde

Please sign in to comment.