我在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];
}
最佳答案
尝试将视图推送到导航控制器
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];
关于ios - subview 添加到导航栏ios,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/11664120/