Navigation bar with single view controller

advertisements

In Xcode there is a template with two controllers and navigation bar. One of them is a table view.

But I need navigation bar with simple view. So, I create new view controller and delegate a root from navigation bar to this view controller.

But instead of my view controller I see just white screen. I suppose it is navigation bar screen. How can I automatically get into my root view controller?

what i see

what i want to see

//  MainViewController.h

#import <UIKit/UIKit.h>

@class ViewController;

@interface MainViewController : UIViewController

@property (strong, nonatomic) IBOutlet UIButton *editButton;

@property (strong, nonatomic) ViewController *detailViewController;

@end

/

/
//  MainViewController.m

#import "MainViewController.h"

#import "ViewController.h"

@interface MainViewController ()

@end

@implementation MainViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end


It seems like you actually are seeing what you want to see. It's just hidden behind the navigation bar. Try re-positioning your label and button so that their y is below that of the navigation bar.

You should be able to see a navigation bar in the view controller through the storyboard, though. Try dragging a new view controller into the storyboard, select it and go to Editor -> Embed in -> Navigation Controller. Then just recreate it.

Also, on a side note, your Details view probably doesn't need a segue back to your Bar Code view. When you have a navigation controller and set the segue from Bar Code to Details as "push", there will be a Back button for you to go back.