1

我正在尝试使用 Ruby Motion 构建一个基本的 Nav + Tab iPhone 应用程序。喜欢这个产品(顺便说一句!)。

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

首先,我在控制器 MatchesListController.rb 中设置标题

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

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

1 回答 1

0

我想通了。我只需要在 app_delegate.rb 中声明它

@postViewController = PostsListController.controller
@postNavController = UINavigationController.alloc.initWithRootViewController(@postViewController)
@postNavController.tabBarItem = UITabBarItem.alloc.initWithTitle('News Feed', image:nil, tag:2)
于 2013-10-05T16:47:38.167 回答