0

我们在应用委托中使用了以下代码。但是我们在导航控制器的 setTitle 函数中遇到了错误。

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    UIViewController *viewController1 = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];
    UIViewController *viewController2 = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
    UIViewController* viewController3=[[ThirdViewController alloc]initWithNibName:@"ThirdViewController" bundle:nil];
    self.tabBarController = [[UITabBarController alloc] init];
    self.tabBarController.viewControllers = [NSArray arrayWithObjects:viewController1, viewController2,viewController3, nil];
    NavigationViewController* navigationViewController=[[NavigationViewController alloc]initWithRootViewController:self.tabBarController];
  self.navigationItem.title=@"news";
    self.window.rootViewController = navigationViewController;
    [self.window makeKeyAndVisible];

    return YES;
}
4

2 回答 2

1
self.navigationItem.title=@"your navigation title";

在您要显示标题的视图控制器中使用它

于 2013-02-22T07:31:53.260 回答
0
[viewController1 setTitle:@"Title1"];
[viewController2 setTitle:@"Title2"];
[viewController3 setTitle:@"Title3"];

带有标题的既不是导航控制器也不是标签栏控制器。

于 2013-02-22T07:54:49.190 回答