导航栏没有出现?

时间:2016-02-17 14:26:53

标签: ios swift uinavigationcontroller uinavigationbar

我目前正在使用名为的表单构建库 尤里卡(https://github.com/xmartlabs/Eureka)由于某种原因 每当我构建一个表单时,导航栏都不会出现 我的视图控制器嵌入在导航控制器中,它是 设置为可见。任何帮助?这是我的回购: https://github.com/ariff20/iTutor

代码

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)
}

输出

1

enter image description here

2

enter image description here

3

enter image description here

3 个答案:

答案 0 :(得分:14)

您正在展示您的ViewController:

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

因此,SignUpViewController实际上并没有UINavigationController作为父母。

这将解决这个问题:

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

答案 1 :(得分:1)

您需要在StoryBoard中使用新的UINavigationBar,然后才能@IBOutlet

@IBOutlet weak var NavigationBar: UINavigationBar!

您将addSubvie UINavigationBar

override func viewDidLoad() {
    super.viewDidLoad()

    self.view.addSubview(NavigationBar)

答案 2 :(得分:1)

Xcode 8.3 +

单击视图控制器并选择以下选项:

编辑器&gt;嵌入&gt;导航控制器

应该这样做。