Question

I'm trying to get a basic Nav + Tab iPhone app up with Ruby Motion. Love the product (BTW!).

The problem is that after build you don't see the tabbar titles. Appreciate any help.

First, I set the title upon init in controller MatchesListController.rb

def init
  #title of first tab
  if super
    self.tabBarItem = UITabBarItem.alloc.initWithTitle('Matches', image:nil, tag:3)
  end
  self
end

Then I load up all the NavControllers into a TabController.

@postViewController = PostsListController.alloc.init
@postNavController = UINavigationController.alloc.initWithRootViewController(@postViewController)

@messagesViewController = MessagesListController.alloc.init
@messagesNavController = UINavigationController.alloc.initWithRootViewController(@messagesViewController)

@matchesViewController = MatchesListController.alloc.init
@matchesNavController = UINavigationController.alloc.initWithRootViewController(@matchesViewController)

@activitiesViewController = ActivitiesListController.alloc.init
@activitiesNavController = UINavigationController.alloc.initWithRootViewController(@activitiesViewController)


@window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)

@tabbar = UITabBarController.alloc.init
@tabbar.viewControllers = [
  @postNavController,
  @messagesNavController,
  @matchesNavController,
  @activitiesNavController
]
@tabbar.selectedIndex = 0

##### NAV CONTROLLER ######

@window.rootViewController = @tabbar
#@window.rootViewController.wantsFullScreenLayout = true
@window.makeKeyAndVisible
Was it helpful?

Solution

I figured this out. I just had to declare it right in the app_delegate.rb

@postViewController = PostsListController.controller
@postNavController = UINavigationController.alloc.initWithRootViewController(@postViewController)
@postNavController.tabBarItem = UITabBarItem.alloc.initWithTitle('News Feed', image:nil, tag:2)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top