The tabs can be created – however, how can you insert a graphic into each tab and when the tabs are selected, how do you call it out to a new screen?
# Create a tabbar
tabbar = UITabBarController.alloc.init
# Each Tab has a view controller allocated
tabbar.viewControllers = [
UIViewController.alloc.init,
UIViewController.alloc.init,
UIViewController.alloc.init,
UIViewController.alloc.init
]
# Selected index to 0
tabbar.selectedIndex = 0
# The root view controller also changed
@window.rootViewController = UINavigationController.alloc.initWithRootViewController(tabbar)
# We will force to use a full screen layout.
@window.rootViewController.wantsFullScreenLayout = true
See the “Beers” sample project at https://github.com/HipByte/RubyMotionSamples
You’re on the right track, the only difference is that you’ll want to list your specific view controller classes instead of the generic UIViewController class. From the sample:
Then in each of those controllers’
initmethods, you set thetabBarItemto give it a title and image:Alternatively, if you don’t have specific view controllers yet, I imagine you could do something like this: