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
Accoording to your description,you want wo show a controller in the present modally
way.Add a UIButton or something like UIButton(UIBarButtonItem).
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)
}
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 !
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.