首页 文章

如何以编程方式向presentModalViewController添加导航栏?

提问于
浏览
1

如何以编程方式向presentModalViewController添加导航栏?我知道pushViewController中会有默认导航栏..希望你的帮助......

3 回答

  • 4

    在viewDidLoad中使用此代码 .

    UINavigationBar *myBar = [[UINavigationBar alloc]initWithFrame:CGRectMake(0, 0, 320, 50)];
    [self.view addSubview:myBar];
    

    这会在您的视图中添加导航栏 .

  • 1

    这可能对你有帮助

    PopoverView *foo = [[PopoverView alloc] initWithNibName:@"PopoverView" bundle:nil];
     // Here you pass through properties if you need too.
     // ...
     UINavigationController *navC = [[UINavigationController alloc] initWithRootView:foo];
     [foo release];
    
     [self.navigationController presentModalViewController:navC animated:YES];
    

    这就是你向模态添加导航栏的方法 .

  • 1

    尝试将此添加到您的View do load

    [self.navigationController setNavigationBarHidden:NO animated:YES];
    

相关问题