Reputation: 142
I am learning the Swift on lessons and have such a project: http://supereasyapps.com/blog/2014/12/15/create-an-ibdesignable-uiview-subclass-with-code-from-an-xib-file-in-xcode-6
I want to click a button "Press me" and go to another View via Navigation Controller (where to be the back button) like this (best if it will be normally on Main.storyboard):
Is it real? Any solutions please? Project on github: https://github.com/PaulSolt/CustomViewFromXib
Upvotes: 0
Views: 710
Reputation: 129
Try this in viewDidLoad
method of ViewController
self.navigationItem.leftBarButtonItem.title = "Press Me"
But I suggested you according to my experience, create your own back button and handle it yourself.
override func viewDidLoad() {
self.navigationItem.backBarButtonItem = UIBarButtonItem(title:"Press Me", style:.Plain, target:nil, action:"backButtonPressed")
}
func backButtonPressed()
{
self.navigationController?.popViewControllerAnimated(true)
}
Upvotes: 0