2012-07-26 213 views
0

我在Ipad上的navigationController.view的子視圖上顯示視圖時遇到問題。我需要在我的viewController(帶有navBar)上顯示透明背景的視圖,但是當我改變方向時,我的navBar在我的視圖的前景上變得可見; 我創建了基於簡單視圖的應用程序。 下面的代碼我加入到項目:子視圖添加到導航欄ios

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]; 
} 

回答

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]; 
+0

我沒有的viewController。我需要顯示navController和navBar上面的自定義視圖。我需要完全覆蓋顯示,因爲當我pushViewController我推我的視圖在navBar下。 – Ncit 2012-07-26 07:36:46

+0

好吧,所以你想要一個自定義欄?你有沒有嘗試工具欄?這些行可能會幫助你與uview一起... ... UINavigationController * navCon = [[UINavigationController alloc] initWithRootViewController:self.viewController]; [navCon setNavigationBarHidden:YES]; self.window.backgroundColor = [UIColor clearColor]; – iMeMyself 2012-07-26 09:19:57

+0

不,我有一個導航欄的應用程序。我需要創建具有透明背景的UIView,它將作爲子視圖添加到viewController中。我需要這樣做,因爲我需要查看我的viewController中的元素。一切工作正常,直到我旋轉設備。當旋轉navBar變得可見時。我需要在屏幕下面看到我的視角。 – Ncit 2012-07-26 09:31:25