1

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
ajbraus
  • 2,909
  • 3
  • 31
  • 45
  • @vacawama is correct. If you don't want to do all this boilerplate, take a look at [ProMotion](https://github.com/clearsightstudio/ProMotion) (/shameless plug). – Jamon Holmgren Oct 03 '13 at 16:03
  • Thanks for the suggestion, but I am shying away from ProMotion because I don't see how I can style the elements it ever-so-magically makes appear on the screen. Have you thought of making some docs for how to integrate with Pixate? Thx! – ajbraus Oct 04 '13 at 16:24
  • Yes, ProMotion works fine with Pixate. I do plan to make some docs for it. I'd recommend first looking at the [styling guide](https://github.com/clearsightstudio/ProMotion/wiki/Guide%3A-Styling-Your-Views). ProMotion screens are just UIViewControllers at heart so you can do anything with them that you can with UIVCs. – Jamon Holmgren Oct 04 '13 at 17:01

1 Answers1

0

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)
ajbraus
  • 2,909
  • 3
  • 31
  • 45