UINaviagtionBar not displaying?

I developing an application in which initially choose UINavigationController based application. In rooViewController xib i added two more UIView, the code is written as follows.

@implementation RootViewController @synthesize introductionView, WheelView;

  • (void)viewDidLoad { [super viewDidLoad]; [self.navigationController setNavigationBarHidden:YES]; }
  • pragma mark

    pragma mark strart up screen:

    -(void)startIntroductionScreen{ if(window == nil) { window = [[UIWindow alloc] initWithFrame:CGRectMake(0, 0, 320, 480)]; } [window addSubview: introductionView]; [window makeKeyAndVisible]; }

    -(void)WheelScreen{ [window addSubview:carnivalWheelView]; [window makeKeyAndVisible]; self.navigationController.navigationBar.hidden = NO;
    [self.navigationItem setLeftBarButtonItem:[[UIBarButtonItem alloc] initWithTitle:@"Setting" style:UIBarButtonItemStylePlain target:nil action:nil] animated:YES]; }

    pragma mark

    pragma mark IBAction:

    -(IBAction)breakGlass:(id)sender{ [self startIntroductionScreen]; }

    -(IBAction)anotherView:(id)sender{ [self WheelScreen]; }

    In above code, when the -(void)WheelScreen method on the IBAction anotherView of invoke the UINaviagtionBar is not displaying.

    Thank's in advance.


    Hi you are adding your view directly to the Window, and it probably has the height 480 px? This means you are covering up the navigationController with the carnivalWheelView.

    The carnivalWheel should be a subclass of UIViewController, you should then add it to the navigationController instead of the window.

    CarnivalWheel *cw = [[CarnivalWheel alloc] init];
    [self.navigationController pushViewController:cw animated:YES];
    [cw release];
    

    Now the CarnivalWheel is a "child" of the navigationController and will not cover it with its view.

    链接地址: http://www.djcxy.com/p/84290.html

    上一篇: 将tableView交换到UITableViewController中的另一个视图中

    下一篇: UINaviagtionBar不显示?