簡體   English   中英

子視圖添加到導航欄ios

[英]subview added to navigationbar ios

我在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];

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM