GenRiH
GenRiH

Reputation: 142

Transition from xib with Navigation Controller

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

The structure of the project The structure of the project

Base Class Base Class

So it looks on an emulator So it looks on an emulator

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): enter image description here

Is it real? Any solutions please? Project on github: https://github.com/PaulSolt/CustomViewFromXib

Upvotes: 0

Views: 710

Answers (1)

Goktug Gumus
Goktug Gumus

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

Related Questions