Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Navigation bar not appearing?

I am currently using a form building library called Eureka(https://github.com/xmartlabs/Eureka) and for some reason whenever I build a form,the navigation bar is not appearing eventhough my view controller is embedded in a navigation controller and it is set to visible.Any help? Here's my repo: https://github.com/ariff20/iTutor

Code

class SignUpViewController: FormViewController ,UINavigationBarDelegate{


override func viewDidLoad() {
    super.viewDidLoad()

     let logButton : UIBarButtonItem = UIBarButtonItem(title: "RightButtonTitle", style: UIBarButtonItemStyle.Done, target: self,action: "multipleSelectorDone")

    self.navigationController?.navigationBar.hidden = false

    self.navigationItem.rightBarButtonItem = logButton
     form +++ Section("Your Basic Details")
        <<< NameRow()
            {
                $0.placeholder = "Your Name"
            }
        <<< EmailRow()
            {
                $0.placeholder = "Email"
            }
        <<< PasswordRow()
            {
                $0.placeholder = "Password"
            }
        <<< PhoneRow()
            {
                $0.placeholder = "Your phone no,Customers will see this"
            }

        +++ Section("Select your Expertise")
        <<< MultipleSelectorRow<String>
            {
                $0.title = "Choose your Subjects"
                $0.options = ["English","Mandarin","Maths","Science","Bahasa Malaysia"]

            }
            .onPresent { from, to in
                to.navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .Done, target: from, action:"multipleSelectorDone:")
        }
        <<< MultipleSelectorRow<String>
            {
                $0.title = "Choose your levels"
                $0.options = ["Standard 1-3","Standard 4-6","Form 1-3","Form 4-5"]

            }
            .onPresent { from, to in
                to.navigationItem.rightBarButtonItem = logButton}

        <<< MultipleSelectorRow<String>
            {
                $0.title = "Choose your pricing range"
                $0.options = ["RM30-RM40","RM40-RM60","RM60-RM80","RM80-RM100"]
            }
            .onPresent { from, to in
                to.navigationItem.rightBarButtonItem = logButton}
        +++ Section("Where can you teach?")
        <<< TextRow()
            {
                $0.placeholder = "State"
            }
        <<< TextRow()
            {
                $0.placeholder = "Town,ex:Near Shah Alam"
            }


    }
override func viewWillAppear(animated: Bool)
{
    super.viewWillAppear(true)
    self.navigationController?.navigationBarHidden=false

}

func multipleSelectorDone(item:UIBarButtonItem)
{

    navigationController?.popViewControllerAnimated(true)
}

OUTPUT

1

enter image description here

2

enter image description here

3

enter image description here

like image 224
Syed Ariff Avatar asked Feb 17 '16 14:02

Syed Ariff


1 Answers

You're presenting your ViewController like this:

let vc = storyboard!.instantiateViewControllerWithIdentifier("TutorSignUp") as! SignUpViewController
self.presentViewController(vc, animated: true, completion: nil)

so your SignUpViewController doesn't actually have a UINavigationController as a parent.

This will fix that:

let vc = storyboard!.instantiateViewControllerWithIdentifier("TutorSignUp") as! SignUpViewController
let navigationController = UINavigationController(rootViewController: vc)
self.presentViewController(navigationController, animated: true, completion: nil)
like image 88
fdiaz Avatar answered Sep 20 '22 21:09

fdiaz