0

I am trying to present a new view after click button in a tableview cell. The view can show up but without the tab bar. Is there any solution that showing the view with tab bar? Thanks.

Storyboard Screenshot

Using segue or progammatically are not right.

  func viewDetailAction(sender: UIButton){
    let vc = self.storyboard?.instantiateViewControllerWithIdentifier("patientDetailVC    ") as! PatientDetailViewController
  //        self.presentViewController(vc, animated: true, completion: nil)
 //        self.navigationController?.pushViewController(vc, animated: true)
     self.performSegueWithIdentifier("patientDetailCell", sender: self)
    }
Janice Zhan
  • 571
  • 1
  • 5
  • 18

2 Answers2

1

A easier way is to present the VC yourself

 self.presentViewController(vc, animated:true, completion:nil)

This will present it on your current VC and not on the tab barController as it is being done probably in the storyboard segue

Please ignore any code syntax mistakes.

Shubhank
  • 21,721
  • 8
  • 65
  • 83
1

Try,

vc.modalPresentationStyle = .OverCurrentContext

after instantiateViewControllerWithIdentifier.

Edit: (using segue)

Simply, delete show segue and use Present Modally segue, click on segue, be sure Over Current Context presentation.

And then use in your action only:

self.performSegueWithIdentifier("overNewPage", sender: nil)

You can reach its properties using prepareForSegue method.

enter image description here

Edit: (using instantiateViewControllerWithIdentifier)

        let viewController = self.storyboard?.instantiateViewControllerWithIdentifier("patientDetailVC") as! PatientDetailViewController
        viewController.modalPresentationStyle = .OverCurrentContext
        viewController.someString = "youCanPassData"

        self.presentViewController(viewController, animated:true, completion:nil)
iamburak
  • 3,508
  • 4
  • 34
  • 65
  • vc.modalPresentationStyle = .OverCurrentContext self.presentViewController(vc, animated: true, completion: nil),,,not working :( – Janice Zhan May 03 '16 at 13:47
  • @JaniceZhan Updated my answer. – iamburak May 03 '16 at 14:07
  • I followed your step but still not working. It sucks! – Janice Zhan May 03 '16 at 14:19
  • @JaniceZhan There are two different way to do it, you are doing something wrong. Make sure your Storyboard ID is correct for second path. They work with me. – iamburak May 03 '16 at 14:24
  • @JaniceZhan For first path, please connect your segue from ViewController, not directly from your button. If you prefer doing directly, you don't need to use `self.performSegueWithIdentifier("overNewPage", sender: nil)`. – iamburak May 03 '16 at 14:30
  • @JaniceZhan For directly segue, make sure you deleted your own action from Connection Inspector. – iamburak May 03 '16 at 14:32