Search code examples
iosxcode4uinavigationbarxcode4.3uinavigationitem

How to create Navigation bar with back button on it?


I am very new to iOS App Development.

In my app I am trying to navigate from second view to first view using navigation bar back button, but while drag and drop the navigation bar in the view I am just able to get the bar with title.

I am really worried and I am not sure what I am doing wrong? I am using Xcode 4.3. and storyboard to design the view.

What i am getting now

While Drag and Drop the Navigation Bar

Looking for

Looking For

Thanks for your help guys


Solution

  • Xcode handles this for you.

    Highlight your first controller. Go to the menu bar and click Embed In > Navigation Controller. Now using UIButton or something, control-click and drag from your first view controller's button to your second view controller and make it a Push segue. The back button won't appear, but if you run it, it will be there.

    So you should have 3 views in storyboard. The Navigation Controller, your first view controller, and your second view controller.

    Here is one way to do it using code.