From cd81cac63580156eb92158bd3007fb3ab73c939a Mon Sep 17 00:00:00 2001 From: Cao yang Date: Wed, 18 Apr 2018 15:56:06 +0800 Subject: [PATCH] 修复成长导航左按钮数据不同步bug --- ParentAssistant/ParentAssistant.xcworkspace/xcuserdata/caoyang.xcuserdatad/UserInterfaceState.xcuserstate | Bin 275347 -> 0 bytes ParentAssistant/ParentAssistant/Classes/controllers/Grow/GrowViewController.swift | 38 ++++++++++++++++++++++++++++---------- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/ParentAssistant/ParentAssistant.xcworkspace/xcuserdata/caoyang.xcuserdatad/UserInterfaceState.xcuserstate b/ParentAssistant/ParentAssistant.xcworkspace/xcuserdata/caoyang.xcuserdatad/UserInterfaceState.xcuserstate index 1cf25e4..24f8631 100644 Binary files a/ParentAssistant/ParentAssistant.xcworkspace/xcuserdata/caoyang.xcuserdatad/UserInterfaceState.xcuserstate and b/ParentAssistant/ParentAssistant.xcworkspace/xcuserdata/caoyang.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/ParentAssistant/ParentAssistant/Classes/controllers/Grow/GrowViewController.swift b/ParentAssistant/ParentAssistant/Classes/controllers/Grow/GrowViewController.swift index a3d5d6b..fd76e89 100644 --- a/ParentAssistant/ParentAssistant/Classes/controllers/Grow/GrowViewController.swift +++ b/ParentAssistant/ParentAssistant/Classes/controllers/Grow/GrowViewController.swift @@ -41,6 +41,9 @@ class GrowViewController: UIViewController,UIScrollViewDelegate { lineLay.backgroundColor = UIColor.white.cgColor return lineLay }() + + var titleLeftLab = UILabel() + //是否显示右侧按钮 var rightBtn = UIBarButtonItem() @@ -52,24 +55,40 @@ class GrowViewController: UIViewController,UIScrollViewDelegate { self.view.addSubview(contentScrollView) self.title = "成长" + //顶部标题 setUpTitle() + //顶部左右按钮 + drawHeadView() + //子控制器 setChildViewContent() + //设置导航栏样式 + self.configTheme() + } + + override func viewWillAppear(_ animated: Bool) { - //左按钮 - let leftView = UIButton.init(frame: CGRect.init(x: 0, y: 0, width: 60, height: 44)) - let titleLab = UILabel.init(frame: CGRect.init(x: 0, y: 0, width: 50, height: 44)) + var title = String() if AccountManager.shared.isOnline() { if AccountManager.shared.rawUserInfo!.contentData()["studentClass"].arrayValue.count == 0 { - titleLab.text = "未绑定" + title = "未绑定" }else{ - titleLab.text = AccountManager.shared.rawUserInfo!.contentData()["studentClass"][0]["studentName"].stringValue + title = AccountManager.shared.rawUserInfo!.contentData()["studentClass"][0]["studentName"].stringValue } }else{ - titleLab.text = "未登录" + title = "未登录" } + self.titleLeftLab.text = title + } + + func drawHeadView () { + //左按钮 + let leftView = UIButton.init(frame: CGRect.init(x: 0, y: 0, width: 60, height: 44)) + let titleLab = UILabel.init(frame: CGRect.init(x: 0, y: 0, width: 50, height: 44)) + titleLab.font = UIFont.systemFont(ofSize: 15) titleLab.textAlignment = .center titleLab.textColor = .white + self.titleLeftLab = titleLab leftView.addSubview(titleLab) let imageView = UIImageView.init(frame: CGRect.init(x: 50, y: 11, width: 10, height: 22)) @@ -77,7 +96,7 @@ class GrowViewController: UIViewController,UIScrollViewDelegate { imageView.contentMode = .scaleAspectFit leftView.addSubview(imageView) -// leftView.addTarget(self, action: #selector(showView), for: UIControlEvents.touchDown) + // leftView.addTarget(self, action: #selector(showView), for: UIControlEvents.touchDown) let leftBtn = UIBarButtonItem.init(customView: leftView) self.navigationItem.leftBarButtonItem = leftBtn @@ -95,13 +114,12 @@ class GrowViewController: UIViewController,UIScrollViewDelegate { imageRView.contentMode = .scaleAspectFit rightView.addSubview(imageRView) -// rightView.addTarget(self, action: #selector(showView), for: UIControlEvents.touchDown) + // rightView.addTarget(self, action: #selector(showView), for: UIControlEvents.touchDown) self.rightBtn = UIBarButtonItem.init(customView: rightView) - //设置顶部样式 - self.configTheme() } + private func setChildViewContent(){ //添加子控制器 -- libgit2 0.21.0