0

I am trying to create a second view controller and I would like to have the same toolbar with buttons that I created and coded from the first view controller without creating and coding that toolbar again. How can I do that?

Tamás Sengel
  • 55,884
  • 29
  • 169
  • 223
Nhat Nguyen
  • 27
  • 1
  • 10

1 Answers1

0

A better approach would be to create the toolbar in a parent view controller. You should use a navigation controller embedded in a container view for that.

This is the scene structure of this approach in Interface Builder:

scene structure

View structure (click to enlarge):

view structure

Use an Embed Segue to display the navigation controller in the container view.

create embed segue from the container view

select Embed in the popup

You can use delegates to pass actions (e.g. a bar button item was tapped).
Read more about delegates in Swift here.

Tamás Sengel
  • 55,884
  • 29
  • 169
  • 223