在 Objective C 中获取 tabBarController 标题

Obtain the tabBarController title in Objective C

我在我的应用程序中使用 UITabBarController,我想知道所选项目的标题以调整我的视图。你知道我该如何继续吗?

谢谢

试试这个

    UINavigationController *currentnavVC = [tabBarController.viewControllers [tabBarController.selectedIndex]];
UITableViewController *currentVC = [currentnavVC topViewController];
    NSString *title = currentVC.title;

试试:(来自你的UITableViewController

NSLog("%@", self.tabBarController.selectedViewController.tabBarItem.title);

这将为您提供当前所选 标签栏项目 的标题。如果你想要当前 View Controller 的标题,你应该使用:

NSLog("%@", self.tabBarController.selectedViewController.title);

我做到了:

NSString *title =[NSString stringWithFormat:@"%@",self.tabBarController.selectedViewController.tabBarItem.title];

谢谢大家的回答