ios – 导航栏没有出现?

前端之家收集整理的这篇文章主要介绍了ios – 导航栏没有出现?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我目前正在使用一个名为的表单构建库
尤里卡( https://github.com/xmartlabs/Eureka)由于某种原因
每当我构建一个表单时,导航栏都不会出现
我的视图控制器嵌入在导航控制器中,它是
设置为可见.任何帮助?这是我的回购:
https://github.com/ariff20/iTutor

  1. class SignUpViewController: FormViewController,UINavigationBarDelegate{
  2.  
  3.  
  4. override func viewDidLoad() {
  5. super.viewDidLoad()
  6.  
  7. let logButton : UIBarButtonItem = UIBarButtonItem(title: "RightButtonTitle",style: UIBarButtonItemStyle.Done,target: self,action: "multipleSelectorDone")
  8.  
  9. self.navigationController?.navigationBar.hidden = false
  10.  
  11. self.navigationItem.rightBarButtonItem = logButton
  12. form +++ Section("Your Basic Details")
  13. <<< NameRow()
  14. {
  15. $0.placeholder = "Your Name"
  16. }
  17. <<< EmailRow()
  18. {
  19. $0.placeholder = "Email"
  20. }
  21. <<< PasswordRow()
  22. {
  23. $0.placeholder = "Password"
  24. }
  25. <<< PhoneRow()
  26. {
  27. $0.placeholder = "Your phone no,Customers will see this"
  28. }
  29.  
  30. +++ Section("Select your Expertise")
  31. <<< MultipleSelectorRow<String>
  32. {
  33. $0.title = "Choose your Subjects"
  34. $0.options = ["English","Mandarin","Maths","Science","Bahasa Malaysia"]
  35.  
  36. }
  37. .onPresent { from,to in
  38. to.navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .Done,target: from,action:"multipleSelectorDone:")
  39. }
  40. <<< MultipleSelectorRow<String>
  41. {
  42. $0.title = "Choose your levels"
  43. $0.options = ["Standard 1-3","Standard 4-6","Form 1-3","Form 4-5"]
  44.  
  45. }
  46. .onPresent { from,to in
  47. to.navigationItem.rightBarButtonItem = logButton}
  48.  
  49. <<< MultipleSelectorRow<String>
  50. {
  51. $0.title = "Choose your pricing range"
  52. $0.options = ["RM30-RM40","RM40-RM60","RM60-RM80","RM80-RM100"]
  53. }
  54. .onPresent { from,to in
  55. to.navigationItem.rightBarButtonItem = logButton}
  56. +++ Section("Where can you teach?")
  57. <<< TextRow()
  58. {
  59. $0.placeholder = "State"
  60. }
  61. <<< TextRow()
  62. {
  63. $0.placeholder = "Town,ex:Near Shah Alam"
  64. }
  65.  
  66.  
  67. }
  68. override func viewWillAppear(animated: Bool)
  69. {
  70. super.viewWillAppear(true)
  71. self.navigationController?.navigationBarHidden=false
  72.  
  73. }
  74.  
  75. func multipleSelectorDone(item:UIBarButtonItem)
  76. {
  77.  
  78. navigationController?.popViewControllerAnimated(true)
  79. }

OUTPUT

1

2

3

解决方法

你正在展示你的ViewController,如下所示:
  1. let vc = storyboard!.instantiateViewControllerWithIdentifier("TutorSignUp") as! SignUpViewController
  2. self.presentViewController(vc,animated: true,completion: nil)

所以你的SignUpViewController实际上没有UINavigationController作为父.

这将解决这个问题:

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

猜你在找的iOS相关文章