0

这是UINavigationController的init方法。我想我一定是做错了。隐藏在内容后面的导航栏

- (id)init 
{ 
self = [super init]; 
if (self) { 

    self.view.backgroundColor = [UIColor blackColor]; 

    self.viewController = [[UIViewController alloc] init]; 

    self.viewControllers = [NSArray arrayWithObject:self.viewController]; 


    UIBarButtonItem *button = [[UIBarButtonItem alloc] initWithTitle:@"Done" 
                   style:UIBarButtonItemStylePlain 
                   target:self 
                   action:@selector(done)]; 
    self.viewController.navigationItem.rightBarButtonItem = button; 
    self.navigationBar.barStyle = UIBarStyleBlackTranslucent; 

    self.mediaScrollView = [[MediaScrollView alloc] initWithFrame:self.view.bounds]; 
    self.mediaScrollView.touchDelegate = self; 
    self.mediaScrollView.fullScreenDelegate = self; 
    [self.viewController.view addSubview:self.mediaScrollView]; 


} 
return self; 

}

的mediaScrollView会在我的导航栏的前面。它应该出现在导航栏后面。

这是调用它的方法:

self.mediaVC = [[PDMediaViewController alloc] init]; 
    self.mediaVC.mediaScrollView.manualMedia = YES; 
    self.mediaVC.mediaScrollView.mediaDelegate = self; 
    self.mediaVC.mediaScrollView.currentMediaItem = 0; 

    self.mediaVC.modalTransitionStyle = UIModalTransitionStyleCrossDissolve; 
    [self presentModalViewController:self.mediaVC animated:YES]; 
+0

不继承UINavigationController的(除非你真的* *知道你在做什么!) –

回答

1

你们中的大多数不继承UINavigationController的时间。相反,您创建UIViewControllers的子类,然后使用正常的UINavigationController实例来处理您的视图控制器。

MyViewController *firstViewController = [[MyViewController alloc] init]; 
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:firstViewController]; 
[window addSubview:navController.view]; 

查看XCode中的导航控制器模板。

+0

所以在我把它叫做类,我得给它像一个半透明的导航栏属性每次? – Andrew

+0

是的。或者在视图控制器的viewWill/DidDisplay方法中。 – DrummerB

0

不要继承UINavigationController!

UINavigationController类实现了管理分层内容导航的专用视图控制器。 此课程不适用于子类别。相反,如果您希望应用程序的用户界面能够反映内容的层次性,您就可以使用它的实例。此导航界面可以有效地呈现您的数据,并且使用户可以更轻松地浏览该内容。

http://developer.apple.com/library/ios/#documentation/uikit/reference/UINavigationController_Class/Reference/Reference.html