title: Swift - How to link two view controllers into one container view and switch between them using segmented control?
body: <p>I got one view controller that contain 1 segmented control and 2 UI views. But I think it's too complicated to update the UI view for enhancement for future editing. I'm using hidden method.</p>
  
  <pre><code>import UIKit
  
  class PopularHistoryViewController: UIViewController {
  
  
      @IBOutlet weak var segmentedControl: UISegmentedControl!
      @IBOutlet weak var popularView: UIView!
      @IBOutlet weak var historyView: UIView!
  
      @IBAction func indexChanged(sender: UISegmentedControl) {
          switch segmentedControl.selectedSegmentIndex
          {
          case 0:
              NSLog("Popular selected")
              //show popular view
              popularView.hidden = false
              historyView.hidden = true
          case 1:
              NSLog("History selected")
              //show history view
              popularView.hidden = true
              historyView.hidden = false
          default:
              break; 
          }
      }
  
      override func viewDidLoad() {
          super.viewDidLoad()
  
          // Do any additional setup after loading the view.
      }
  
  }
  </code></pre>
  
  <p>What I want is 1 container view that contain 2 controller views so I can switch them using segmented control.</p>
  
  <p><img src="https://i.stack.imgur.com/PpPp8.png" alt="enter image description here"></p>