Commit cd81cac63580156eb92158bd3007fb3ab73c939a

Authored by Cao yang
1 parent 98a07100
Exists in parentassistant

修复成长导航左按钮数据不同步bug

ParentAssistant/ParentAssistant.xcworkspace/xcuserdata/caoyang.xcuserdatad/UserInterfaceState.xcuserstate
No preview for this file type
ParentAssistant/ParentAssistant/Classes/controllers/Grow/GrowViewController.swift
... ... @@ -41,6 +41,9 @@ class GrowViewController: UIViewController,UIScrollViewDelegate {
41 41 lineLay.backgroundColor = UIColor.white.cgColor
42 42 return lineLay
43 43 }()
  44 +
  45 + var titleLeftLab = UILabel()
  46 +
44 47 //是否显示右侧按钮
45 48 var rightBtn = UIBarButtonItem()
46 49  
... ... @@ -52,24 +55,40 @@ class GrowViewController: UIViewController,UIScrollViewDelegate {
52 55 self.view.addSubview(contentScrollView)
53 56  
54 57 self.title = "成长"
  58 + //顶部标题
55 59 setUpTitle()
  60 + //顶部左右按钮
  61 + drawHeadView()
  62 + //子控制器
56 63 setChildViewContent()
  64 + //设置导航栏样式
  65 + self.configTheme()
  66 + }
  67 +
  68 + override func viewWillAppear(_ animated: Bool) {
57 69  
58   - //左按钮
59   - let leftView = UIButton.init(frame: CGRect.init(x: 0, y: 0, width: 60, height: 44))
60   - let titleLab = UILabel.init(frame: CGRect.init(x: 0, y: 0, width: 50, height: 44))
  70 + var title = String()
61 71 if AccountManager.shared.isOnline() {
62 72 if AccountManager.shared.rawUserInfo!.contentData()["studentClass"].arrayValue.count == 0 {
63   - titleLab.text = "未绑定"
  73 + title = "未绑定"
64 74 }else{
65   - titleLab.text = AccountManager.shared.rawUserInfo!.contentData()["studentClass"][0]["studentName"].stringValue
  75 + title = AccountManager.shared.rawUserInfo!.contentData()["studentClass"][0]["studentName"].stringValue
66 76 }
67 77 }else{
68   - titleLab.text = "未登录"
  78 + title = "未登录"
69 79 }
  80 + self.titleLeftLab.text = title
  81 + }
  82 +
  83 + func drawHeadView () {
  84 + //左按钮
  85 + let leftView = UIButton.init(frame: CGRect.init(x: 0, y: 0, width: 60, height: 44))
  86 + let titleLab = UILabel.init(frame: CGRect.init(x: 0, y: 0, width: 50, height: 44))
  87 +
70 88 titleLab.font = UIFont.systemFont(ofSize: 15)
71 89 titleLab.textAlignment = .center
72 90 titleLab.textColor = .white
  91 + self.titleLeftLab = titleLab
73 92 leftView.addSubview(titleLab)
74 93  
75 94 let imageView = UIImageView.init(frame: CGRect.init(x: 50, y: 11, width: 10, height: 22))
... ... @@ -77,7 +96,7 @@ class GrowViewController: UIViewController,UIScrollViewDelegate {
77 96 imageView.contentMode = .scaleAspectFit
78 97 leftView.addSubview(imageView)
79 98  
80   -// leftView.addTarget(self, action: #selector(showView), for: UIControlEvents.touchDown)
  99 + // leftView.addTarget(self, action: #selector(showView), for: UIControlEvents.touchDown)
81 100  
82 101 let leftBtn = UIBarButtonItem.init(customView: leftView)
83 102 self.navigationItem.leftBarButtonItem = leftBtn
... ... @@ -95,13 +114,12 @@ class GrowViewController: UIViewController,UIScrollViewDelegate {
95 114 imageRView.contentMode = .scaleAspectFit
96 115 rightView.addSubview(imageRView)
97 116  
98   -// rightView.addTarget(self, action: #selector(showView), for: UIControlEvents.touchDown)
  117 + // rightView.addTarget(self, action: #selector(showView), for: UIControlEvents.touchDown)
99 118 self.rightBtn = UIBarButtonItem.init(customView: rightView)
100 119  
101   - //设置顶部样式
102   - self.configTheme()
103 120 }
104 121  
  122 +
105 123 private func setChildViewContent(){
106 124  
107 125 //添加子控制器
... ...