1

I have custom navigation bar and content a button bar I need create segue from my bar button to my custom navigation with kind present modally but programmatically not from storyboard this work but segue kind is push

self.navigationController?.pushViewController("", animated: true)

what I should do get it with present modally

joda
  • 711
  • 2
  • 8
  • 16

2 Answers2

0

Accoording to your description,you want wo show a controller in the present modally way.Add a UIButton or something like UIButton(UIBarButtonItem).

enter image description here

How about this:

override func viewDidLoad() {
    super.viewDidLoad()

    let rightButton = UIBarButtonItem(title: "present", style: .Plain, target: self, action: #selector(clickRightItem))
    navigationItem.rightBarButtonItem = rightButton;
}

func clickRightItem() {
    let controllerToPresent = UIViewController()
    controllerToPresent.view.backgroundColor = UIColor.redColor()
    presentViewController(controllerToPresent, animated: true, completion: nil)

}
Tony
  • 542
  • 3
  • 13
0

this is a simple solution with a NavigationController to present modally .

yourviewcontroller *myviewc= [[yourviewcontroller alloc] init];
[self presentViewController:myviewc animated:YES completion:nil];

and for the seconde if you have a navigation controller .

let myvc= self.storyboard!.instantiateViewControllerWithIdentifier("MyViewController") as! ViewController
    let navc= UINavigationController(rootViewController: myvc) 
    self.presentViewController(navc, animated:true, completion: nil)

You need just to create an IBAction for your Button. this Tutorial can help you to do it IBAction

Hope it help !

MedAmine.Rihane
  • 1,193
  • 10
  • 17