子视图添加到导航栏ios

时间:2012-07-26 07:05:09

标签: ios ipad subview navbar

我在Ipad上的navigationController.view上显示视图作为子视图时遇到问题。我需要在viewController上显示带有透明背景的视图(使用navBar),但是当我改变方向时,我的navBar在我视图的foreGround上变得可见; 我创建了基于简单视图的应用。 这里代码我添加到项目:

AppDelegate.h:

 UINavigationController *_navController;

@property (strong, nonatomic) UINavigationController *navController;

AppDelegate.m:

_navController = [[[UINavigationController alloc] initWithRootViewController:self.viewController] autorelease];
    self.window.rootViewController = _navController;

ViewController.m:

- (void)viewDidLoad
{
    [super viewDidLoad];
    UIView *view = [[[UIView alloc] initWithFrame:self.view.frame] autorelease];
    [view setBackgroundColor:[UIColor redColor]];

    [self.navigationController.view addSubview:view];
}

1 个答案:

答案 0 :(得分:2)

尝试将视图推送到导航控制器

 YourAppDelegate *del = (YourAppDelegate *)[UIApplication sharedApplication].delegate;
[del.navigationController pushViewController:nextViewController animated:YES];

UINavigationController* navigation = [[UINavigationController alloc] init];
 iVkViewController *overviewViewController = [[iVkViewController alloc] init];
 overviewViewController.title = @"First";
 [navigation pushViewController:overviewViewController animated:NO];