Commit cd81cac63580156eb92158bd3007fb3ab73c939a
1 parent
98a07100
Exists in
parentassistant
修复成长导航左按钮数据不同步bug
Showing
2 changed files
with
28 additions
and
10 deletions
Show diff stats
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,6 +41,9 @@ class GrowViewController: UIViewController,UIScrollViewDelegate { | ||
41 | lineLay.backgroundColor = UIColor.white.cgColor | 41 | lineLay.backgroundColor = UIColor.white.cgColor |
42 | return lineLay | 42 | return lineLay |
43 | }() | 43 | }() |
44 | + | ||
45 | + var titleLeftLab = UILabel() | ||
46 | + | ||
44 | //是否显示右侧按钮 | 47 | //是否显示右侧按钮 |
45 | var rightBtn = UIBarButtonItem() | 48 | var rightBtn = UIBarButtonItem() |
46 | 49 | ||
@@ -52,24 +55,40 @@ class GrowViewController: UIViewController,UIScrollViewDelegate { | @@ -52,24 +55,40 @@ class GrowViewController: UIViewController,UIScrollViewDelegate { | ||
52 | self.view.addSubview(contentScrollView) | 55 | self.view.addSubview(contentScrollView) |
53 | 56 | ||
54 | self.title = "成长" | 57 | self.title = "成长" |
58 | + //顶部标题 | ||
55 | setUpTitle() | 59 | setUpTitle() |
60 | + //顶部左右按钮 | ||
61 | + drawHeadView() | ||
62 | + //子控制器 | ||
56 | setChildViewContent() | 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 | if AccountManager.shared.isOnline() { | 71 | if AccountManager.shared.isOnline() { |
62 | if AccountManager.shared.rawUserInfo!.contentData()["studentClass"].arrayValue.count == 0 { | 72 | if AccountManager.shared.rawUserInfo!.contentData()["studentClass"].arrayValue.count == 0 { |
63 | - titleLab.text = "未绑定" | 73 | + title = "未绑定" |
64 | }else{ | 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 | }else{ | 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 | titleLab.font = UIFont.systemFont(ofSize: 15) | 88 | titleLab.font = UIFont.systemFont(ofSize: 15) |
71 | titleLab.textAlignment = .center | 89 | titleLab.textAlignment = .center |
72 | titleLab.textColor = .white | 90 | titleLab.textColor = .white |
91 | + self.titleLeftLab = titleLab | ||
73 | leftView.addSubview(titleLab) | 92 | leftView.addSubview(titleLab) |
74 | 93 | ||
75 | let imageView = UIImageView.init(frame: CGRect.init(x: 50, y: 11, width: 10, height: 22)) | 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,7 +96,7 @@ class GrowViewController: UIViewController,UIScrollViewDelegate { | ||
77 | imageView.contentMode = .scaleAspectFit | 96 | imageView.contentMode = .scaleAspectFit |
78 | leftView.addSubview(imageView) | 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 | let leftBtn = UIBarButtonItem.init(customView: leftView) | 101 | let leftBtn = UIBarButtonItem.init(customView: leftView) |
83 | self.navigationItem.leftBarButtonItem = leftBtn | 102 | self.navigationItem.leftBarButtonItem = leftBtn |
@@ -95,13 +114,12 @@ class GrowViewController: UIViewController,UIScrollViewDelegate { | @@ -95,13 +114,12 @@ class GrowViewController: UIViewController,UIScrollViewDelegate { | ||
95 | imageRView.contentMode = .scaleAspectFit | 114 | imageRView.contentMode = .scaleAspectFit |
96 | rightView.addSubview(imageRView) | 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 | self.rightBtn = UIBarButtonItem.init(customView: rightView) | 118 | self.rightBtn = UIBarButtonItem.init(customView: rightView) |
100 | 119 | ||
101 | - //设置顶部样式 | ||
102 | - self.configTheme() | ||
103 | } | 120 | } |
104 | 121 | ||
122 | + | ||
105 | private func setChildViewContent(){ | 123 | private func setChildViewContent(){ |
106 | 124 | ||
107 | //添加子控制器 | 125 | //添加子控制器 |