Ruby Motion中的导航+选项卡 - 加载时不显示标签栏标题

时间:2013-10-02 13:28:34

标签: uinavigationcontroller uitabbarcontroller uitabbaritem rubymotion

我正在尝试使用Ruby Motion获取基本的Nav + Tab iPhone应用程序。喜欢这个产品(BTW!)。

问题是,在构建之后,您看不到标签栏标题。感谢任何帮助。

首先,我在控制器MatchesListController.rb

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

然后我将所有NavControllers加载到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

1 个答案:

答案 0 :(得分:0)

我想出来了。我只需要在app_delegate.rb

中声明它
@postViewController = PostsListController.controller
@postNavController = UINavigationController.alloc.initWithRootViewController(@postViewController)
@postNavController.tabBarItem = UITabBarItem.alloc.initWithTitle('News Feed', image:nil, tag:2)