Ver código fonte

textField 内存泄露bug修复

南鑫林 5 anos atrás
pai
commit
8671e56c3b
19 arquivos alterados com 142 adições e 113 exclusões
  1. 1 1
      RainbowPlanet/RainbowPlanet/Manager/AliyunVodManager/AliyunVodUpToyoPublishManager/PublishUploadProgressView.swift
  2. 4 1
      RainbowPlanet/RainbowPlanet/Modules/CommunityModule/Community/View/Cell/FollowStatus/CommunityFollowStatusTableViewCell.swift
  3. 2 12
      RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityRecommendDetail/Controller/CommunityRecommendController.swift
  4. 1 1
      RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityRecommendDetail/View/AllCommentCell/RecommendSubCommentTableViewFooter.swift
  5. 27 15
      RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityRecommendDetail/View/HTMLCell/CommunityRecommendDetailHTMLTableViewCell.swift
  6. 2 2
      RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityVideoContent/View/CommunityVideoCoverCollectionCell.swift
  7. 2 2
      RainbowPlanet/RainbowPlanet/Modules/MineModule/MyFollowAndFan/View/MyFollowAndFanHeaderView.swift
  8. 9 8
      RainbowPlanet/RainbowPlanet/Modules/MineModule/MyFollowAndFan/ViewController/MyFollowAndFanViewController.swift
  9. 2 2
      RainbowPlanet/RainbowPlanet/Modules/RegisterLoginModule/PasswordLogin/View/PasswordLoginView.swift
  10. 37 27
      RainbowPlanet/RainbowPlanet/Modules/SearchModule/Search/View/SearchNavigationbarView.swift
  11. 1 1
      RainbowPlanet/RainbowPlanet/Modules/SearchModule/Search/View/SearchView.swift
  12. 4 4
      RainbowPlanet/RainbowPlanet/Modules/SearchModule/Search/ViewController/SearchViewController.swift
  13. 1 1
      RainbowPlanet/RainbowPlanet/Modules/SearchModule/SearchContentList/ViewController/SearchContentListViewController.swift
  14. 36 24
      RainbowPlanet/RainbowPlanet/Modules/SearchModule/SearchResult/View/SearchResultNavigationbarView.swift
  15. 6 7
      RainbowPlanet/RainbowPlanet/Modules/SearchModule/SearchResult/ViewController/SearchResultViewController.swift
  16. 5 2
      RainbowPlanet/RainbowPlanet/Modules/SearchModule/SearchUser/View/SearchUserLitTableViewCell.swift
  17. 1 1
      RainbowPlanet/RainbowPlanet/Service/SwiftMoyaService/SwiftMoyaServiceApi/SwiftMoyaServiceCommunity/SwiftMoyaNetWorkServiceCommunity.swift
  18. 1 1
      RainbowPlanet/RainbowPlanet/Service/SwiftMoyaService/SwiftMoyaServiceApi/SwiftMoyaServiceUser/SwiftMoyaNetWorkServiceUser.swift
  19. 0 1
      RainbowPlanet/RainbowPlanet/ViewModel/Community/CommunityFollowUserViewModel.swift

+ 1 - 1
RainbowPlanet/RainbowPlanet/Manager/AliyunVodManager/AliyunVodUpToyoPublishManager/PublishUploadProgressView.swift

@@ -95,7 +95,7 @@ class PublishUploadProgressView: FWPopupView {
     private lazy var progressView: UIProgressView = {
         let progressView = UIProgressView(progressViewStyle: .default)
         progressView.setProgress(0, animated: false)
-        progressView.progressTintColor = k62CC74Color //进度颜色
+        progressView.progressTintColor = kThemeColor //进度颜色
         progressView.trackTintColor = kd8d8d8Color //剩余进度颜色
         progressView.cornerRadius = 2
         progressView.masksToBounds = true

+ 4 - 1
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/Community/View/Cell/FollowStatus/CommunityFollowStatusTableViewCell.swift

@@ -93,6 +93,7 @@ class CommunityFollowStatusTableViewCell: UITableViewCell {
         titleOtherButton.snp_makeConstraints { (make) in
             make.centerY.equalTo(avatarOtherButton)
             make.left.equalTo(avatarOtherButton.snp_right).offset(16)
+            make.right.equalTo(followButton.snp.left).offset(-5)
         }
         
         followButton.snp_makeConstraints { (make) in
@@ -148,6 +149,7 @@ class CommunityFollowStatusTableViewCell: UITableViewCell {
         let avatarButton = UIButton(type: UIButton.ButtonType.custom)
         avatarButton.setImage(kImage(name: "default_avatar"), for: UIControl.State.normal)
         avatarButton.imageView?.contentMode = .scaleAspectFill
+        avatarButton.imageView?.clipsToBounds = true
         avatarButton.cornerRadius = 14
         avatarButton.masksToBounds = true
         avatarButton.rx.tap.subscribe(onNext: { [weak self] (data) in
@@ -188,6 +190,7 @@ class CommunityFollowStatusTableViewCell: UITableViewCell {
         let avatarOtherButton = UIButton(type: UIButton.ButtonType.custom)
         avatarOtherButton.setImage(kImage(name: "default_pic"), for: UIControl.State.normal)
         avatarOtherButton.imageView?.contentMode = .scaleAspectFill
+        avatarOtherButton.imageView?.clipsToBounds = true
         avatarOtherButton.cornerRadius = 20
         avatarOtherButton.masksToBounds = true
         avatarOtherButton.rx.tap.subscribe(onNext: {
@@ -312,7 +315,7 @@ class CommunityFollowStatusTableViewCell: UITableViewCell {
             switch communityFollowType {
             case .follow?:
                 timeStatusLabel.text = "\(communityFollowDataModel?.createdAt ?? "") 关注了"
-                avatarOtherButton.kf.setImage(with: kURLThumbnailsImage(name: communityFollowDataModel?.relateData?.avatar ?? "",size: kSize20x20Image), for: UIControl.State.normal , placeholder: kImage(name: "default_avatar"))
+                avatarOtherButton.kf.setImage(with: kURLThumbnailsImage(name: communityFollowDataModel?.relateData?.avatar ?? "",size: kSize40x40Image), for: UIControl.State.normal , placeholder: kImage(name: "default_avatar"))
                 
 
                 titleOtherButton.setTitle(communityFollowDataModel?.relateData?.username, for: UIControl.State.normal)

+ 2 - 12
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityRecommendDetail/Controller/CommunityRecommendController.swift

@@ -17,7 +17,6 @@ class CommunityRecommendController: BaseViewController {
     
     deinit {
         NXLLog("deinit")
-        self.view = nil
         if observe != nil {
             NotificationCenter.default.removeObserver(observe!)
         }
@@ -196,7 +195,6 @@ class CommunityRecommendController: BaseViewController {
                 kAppDelegate.setLogin()
             }else {
                 self?.share()
-
             }
         }
         sharedButton.rx.tap.subscribe(onNext: { [weak self] _ in
@@ -270,7 +268,6 @@ class CommunityRecommendController: BaseViewController {
             if self?.communityPostDetailModel?.id == followStatusModel?.postId {
                 self?.communityPostDetailModel?.isCollect = followStatusModel?.isFollowStatus
                 self?.commentView.communityPostDetailModel = self?.communityPostDetailModel
-                self?.tableView.reloadData()
             }
             self?.tableView.reloadData()
         }
@@ -366,9 +363,8 @@ extension CommunityRecommendController {
             if self?.communityPostDetailModel?.uid == UserModel.shared().getModel()?.uid {
                 self?.followButton.isHidden = true
             }else {
-                self?.followButton.isHidden = false
+                CommunityFollowUserViewModel.setFollowListType(followButton: self?.followButton, followType: FollowType(rawValue: self?.communityPostDetailModel?.isFollow ?? 0) ?? .futureFollow)
             }
-            CommunityFollowUserViewModel.setFollowType(followButton: self?.followButton, followType: FollowType(rawValue: self?.communityPostDetailModel?.isFollow ?? 0) ?? .futureFollow)
             self?.commentView.communityPostDetailModel = self?.communityPostDetailModel
             self?.count = self?.communityPostDetailModel?.commentCount ?? 0
             
@@ -377,12 +373,6 @@ extension CommunityRecommendController {
                 self?.nameButton.isHidden = true
                 self?.followButton.isHidden = true
             }else {
-                if self?.communityPostDetailModel?.uid != UserModel.shared().getModel()?.uid {
-                    self?.followButton.isHidden = false
-                }else {
-                    self?.followButton.isHidden = true
-                }
-
                 self?.communityPostDetailTableViewHeaderView.frame = CGRect(x: 0, y: 0, width: kScreenWidth, height: kScreenWidth)
 
                 if !(self?.communityPostDetailModel?.imgs?.isEmpty ?? true) {
@@ -689,7 +679,7 @@ extension CommunityRecommendController: UITableViewDataSource, UITableViewDelega
                                 [weak self] in
                                 self?.communityPostCommentModel?.isDelete = 1
                                 self?.communityPostCommentModel?.content = "该评论已被删除"
-                                tableView.reloadData()
+                                self?.tableView.reloadData()
                         })
                     }else {
                         SwiftProgressHUD.shared().showText("该评论已删除,暂时不能评论")

+ 1 - 1
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityRecommendDetail/View/AllCommentCell/RecommendSubCommentTableViewFooter.swift

@@ -29,7 +29,7 @@ class RecommendSubCommentTableViewFooter: BaseView {
     
     private lazy var unfoldBtn: UIButton = {
         let unfoldBtn = UIButton(type: UIButton.ButtonType.custom)
-        unfoldBtn.setTitleColor(k62CC74Color, for: .normal)
+        unfoldBtn.setTitleColor(kThemeColor, for: .normal)
         unfoldBtn.titleLabel?.font = kRegularFont14
         unfoldBtn.rx.tap.subscribe(onNext: { [weak self] (data) in
             if let unfoldClosure = self?.unfoldClosure {

+ 27 - 15
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityRecommendDetail/View/HTMLCell/CommunityRecommendDetailHTMLTableViewCell.swift

@@ -16,7 +16,6 @@ class CommunityRecommendDetailHTMLTableViewCell: UITableViewCell {
     
     let disposeBag = DisposeBag()
     
-    
     deinit {
         NXLLog("deinit")
         webView.scrollView.removeObserver(self, forKeyPath: "contentSize")
@@ -34,6 +33,7 @@ class CommunityRecommendDetailHTMLTableViewCell: UITableViewCell {
         super.init(style: style, reuseIdentifier: reuseIdentifier)
         setupViews()
         setupLayouts()
+        setupdata()
     }
     
     required init?(coder aDecoder: NSCoder) {
@@ -120,6 +120,17 @@ class CommunityRecommendDetailHTMLTableViewCell: UITableViewCell {
         }
     }
     
+    func setupdata() {
+        followButton.rx.tap.subscribe(onNext: { [weak self] (data) in
+            if UserModel.isTokenNil() {
+                kAppDelegate.setLogin()
+            }else {
+                CommunityFollowUserViewModel.shared.follow(communityPostDetailModel: (self?.communityPostDetailModel)!, button: (self?.followButton)!)
+                
+            }
+        }).disposed(by: disposeBag)
+    }
+    
     private lazy var titleLabel: UILabel = {
         let titleLabel = UILabel()
         titleLabel.textColor = k262626Color
@@ -157,14 +168,6 @@ class CommunityRecommendDetailHTMLTableViewCell: UITableViewCell {
         followButton.masksToBounds = true
         followButton.layer.borderWidth = 0.5
         followButton.isHidden = true
-        followButton.rx.tap.subscribe(onNext: { [weak self] (data) in
-            if UserModel.isTokenNil() {
-                kAppDelegate.setLogin()
-            }else {
-                CommunityFollowUserViewModel.shared.follow(communityPostDetailModel: (self?.communityPostDetailModel)!, button: (self?.followButton)!)
-                
-            }
-        }).disposed(by: disposeBag)
         return followButton
     }()
     
@@ -200,7 +203,6 @@ class CommunityRecommendDetailHTMLTableViewCell: UITableViewCell {
     }()
     
     private lazy var collectionView: UICollectionView = {
-        [unowned self] in
         let collectionView = UICollectionView.init(frame: CGRect.zero, collectionViewLayout: collectionViewLayout)
         collectionView.backgroundColor = kffffffColor
         collectionView.delegate = self
@@ -212,8 +214,18 @@ class CommunityRecommendDetailHTMLTableViewCell: UITableViewCell {
         return collectionView
     }()
     
-    private lazy var collectionViewLayout: UICollectionViewLeftAlignedLayout = {
-        let collectionViewLayout = UICollectionViewLeftAlignedLayout.init()
+//    private lazy var collectionViewLayout: UICollectionViewLeftAlignedLayout = {
+//        let collectionViewLayout = UICollectionViewLeftAlignedLayout.init()
+//        collectionViewLayout.minimumLineSpacing = 10
+//        collectionViewLayout.minimumInteritemSpacing =  10
+//        collectionViewLayout.scrollDirection = UICollectionView.ScrollDirection.vertical
+//        collectionViewLayout.estimatedItemSize = CGSize(width: ((kScreenWidth - 28) - 30)/4, height: 24)
+//        collectionViewLayout.sectionInset = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
+//        return collectionViewLayout
+//    }()
+    
+    private lazy var collectionViewLayout: UICollectionViewFlowLayout = {
+        let collectionViewLayout = UICollectionViewFlowLayout()
         collectionViewLayout.minimumLineSpacing = 10
         collectionViewLayout.minimumInteritemSpacing =  10
         collectionViewLayout.scrollDirection = UICollectionView.ScrollDirection.vertical
@@ -256,7 +268,6 @@ class CommunityRecommendDetailHTMLTableViewCell: UITableViewCell {
     }
     var tableView:UITableView?
     
-    
     var communityPostDetailModel : CommunityPostDetailModel? {
         didSet {
             
@@ -370,9 +381,10 @@ extension CommunityRecommendDetailHTMLTableViewCell: UICollectionViewDelegateFlo
 
 extension CommunityRecommendDetailHTMLTableViewCell {
     override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
+        weak var weakself = self
         if keyPath == "contentSize" {
-            webViewCellHeight = self.webView.scrollView.contentSize.height
-            tableView?.reloadData()
+            webViewCellHeight = weakself?.webView.scrollView.contentSize.height
+            weakself?.tableView?.reloadData()
         }
     }
 }

+ 2 - 2
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityVideoContent/View/CommunityVideoCoverCollectionCell.swift

@@ -883,9 +883,9 @@ class CommunityVideoCoverCollectionCell: UICollectionViewCell {
             if self.videoItemMdl?.uid == UserModel.shared().getModel()?.uid {
                 followButton.isHidden = true
             } else {
-                followButton.isHidden = false
+                CommunityFollowUserViewModel.shared.setVideoFollowType(followButton: followButton, followType: FollowType(rawValue: self.videoItemMdl?.isFollow ?? 0)!)
             }
-            CommunityFollowUserViewModel.shared.setVideoFollowType(followButton: followButton, followType: FollowType(rawValue: self.videoItemMdl?.isFollow ?? 0)!)
+
             
             if !(self.videoItemMdl?.title == "" || self.videoItemMdl?.title == nil) {
                 // 有标题

+ 2 - 2
RainbowPlanet/RainbowPlanet/Modules/MineModule/MyFollowAndFan/View/MyFollowAndFanHeaderView.swift

@@ -27,8 +27,8 @@ class MyFollowAndFanHeaderView: BaseView {
         let titleLabel = UILabel()
         titleLabel.font = kRegularFont12
         titleLabel.textColor = k333333Color
-        let str = "已关注3511位老板"
-        titleLabel.attributedText = str.changeTextColor(rangStr: String("3511"), rangColor: kThemeColor)
+        let str = "已关注0位老板"
+        titleLabel.attributedText = str.changeTextColor(rangStr: String("0"), rangColor: kThemeColor)
         return titleLabel
     }()
     

+ 9 - 8
RainbowPlanet/RainbowPlanet/Modules/MineModule/MyFollowAndFan/ViewController/MyFollowAndFanViewController.swift

@@ -132,13 +132,14 @@ extension MyFollowAndFanViewController {
     
     /// 获取粉丝列表
     func userFans(page:Int = 1) {
-        SwiftMoyaNetWorkServiceUser.shared().userFansApi(uid: self.userDetailModel?.uid ?? 0, page: page,completion: {[weak self] (userFansModel) -> (Void) in
+        SwiftMoyaNetWorkServiceUser.shared().userFansApi(uid: self.userDetailModel?.uid ?? 0, page: page,completion: { [weak self] (userFansModel) in
             DIYEmptyView.emptyNoDataActionTableView(tableView: self?.tableView, imageStr: .seven, detailStr: .seven, btnTitleStr: .four, btnClickBlock: {
                 [weak self] in
                 if BaseTabbarViewController.shared.v1.navigationBarbgView.isHidden {
                     let pickVc = PublishViewController()
                     let nav = BaseNavigationViewController.init(rootViewController: pickVc)
                     self?.tabBarController?.present(nav, animated: true, completion: {
+                        [weak self] in
                         self?.navigationController?.popToRootViewController(animated: false)
                     })
                 } else {
@@ -209,28 +210,28 @@ extension MyFollowAndFanViewController: UITableViewDataSource, UITableViewDelega
             cell.userFanModel = userFanModels[indexPath.row]
         }
         cell.followButtonClosure = {
-            [weak self] in
+            [weak self,weak cell] in
             if self?.myfollowAndFanType == .follow {
-                if cell.userFollowModel?.isFollowStatus == 0 { //加关注
-                    self?.userFollow(followUid: cell.userFollowModel?.followUid ?? 0, completion: {[weak self,weak cell] (isFollow) -> Void in
+                if cell?.userFollowModel?.isFollowStatus == 0 { //加关注
+                    self?.userFollow(followUid: cell?.userFollowModel?.followUid ?? 0, completion: {[weak self,weak cell] (isFollow) -> Void in
                         cell?.userFollowModel?.isFollowStatus = isFollow
                         self?.tableView.reloadRows(at: [indexPath], with: UITableView.RowAnimation.none)
                     })
                 }else { //取消关注
-                    self?.userCancelFollow(followUid: cell.userFollowModel?.followUid ?? 0, completion: { [weak self,weak cell] (isFollow) -> Void in
+                    self?.userCancelFollow(followUid: cell?.userFollowModel?.followUid ?? 0, completion: { [weak self,weak cell] (isFollow) -> Void in
                         cell?.userFollowModel?.isFollowStatus = isFollow
                         self?.tableView.reloadRows(at: [indexPath], with: UITableView.RowAnimation.none)
                     })
                 }
 
             }else if self?.myfollowAndFanType == .fan {
-                if cell.userFanModel?.isFollowStatus == 0 {//加关注
-                    self?.userFollow(followUid: cell.userFanModel?.fanUid ?? 0, completion: {[weak self,weak cell] (isFollow) -> Void in
+                if cell?.userFanModel?.isFollowStatus == 0 {//加关注
+                    self?.userFollow(followUid: cell?.userFanModel?.fanUid ?? 0, completion: {[weak self,weak cell] (isFollow) -> Void in
                         cell?.userFanModel?.isFollowStatus = isFollow
                         self?.tableView.reloadRows(at: [indexPath], with: UITableView.RowAnimation.none)
                     })
                 }else {//取消关注
-                    self?.userCancelFollow(followUid: cell.userFanModel?.fanUid ?? 0, completion: {[weak self,weak cell] (isFollow) -> Void in
+                    self?.userCancelFollow(followUid: cell?.userFanModel?.fanUid ?? 0, completion: {[weak self,weak cell] (isFollow) -> Void in
                         cell?.userFanModel?.isFollowStatus = isFollow
                         self?.tableView.reloadRows(at: [indexPath], with: UITableView.RowAnimation.none)
                     })

+ 2 - 2
RainbowPlanet/RainbowPlanet/Modules/RegisterLoginModule/PasswordLogin/View/PasswordLoginView.swift

@@ -235,8 +235,8 @@ class PasswordLoginView: BaseView {
         saftButton.setImage(kImage(name: "login_show"), for: UIControl.State.normal)
         saftButton.setImage(kImage(name: "login_show_pressed"), for: UIControl.State.selected)
         saftButton.rx.tap.subscribe(onNext: { [weak self] (data) in
-            saftButton.isSelected = !saftButton.isSelected
-            self?.passwordTextField.isSecureTextEntry = saftButton.isSelected
+            self?.saftButton.isSelected = !(self?.saftButton.isSelected)!
+            self?.passwordTextField.isSecureTextEntry = (self?.saftButton.isSelected)!
         }).disposed(by: disposeBag)
         return saftButton
     }()

+ 37 - 27
RainbowPlanet/RainbowPlanet/Modules/SearchModule/Search/View/SearchNavigationbarView.swift

@@ -12,6 +12,8 @@ class SearchNavigationbarView: BaseView {
     
     deinit{
         NXLLog("deinit")
+        searchTextField.delegate = nil
+
     }
     
     typealias CancelBlock = () -> Void
@@ -54,33 +56,6 @@ class SearchNavigationbarView: BaseView {
         }
     }
     override func setupData() {
-        searchTextField.rx.controlEvent([.editingDidEndOnExit]).asObservable().subscribe(onNext: {
-            [weak self] (text) in
-            
-            if self?.searchTextField.text?.count ?? 0 > 0 {
-                self?.endEditing(true)
-                
-                var searchHistoryArray = Array<String>()
-                
-                if UserDefaults.standard.array(forKey: "SearchHistoryArray")?.isEmpty ?? true {
-                    searchHistoryArray.insert(self?.searchTextField.text ?? "", at: 0)
-                } else {
-                    searchHistoryArray = UserDefaults.standard.array(forKey: "SearchHistoryArray") as! [String]
-                    if !(searchHistoryArray.contains(self?.searchTextField.text ?? "")) {
-                        searchHistoryArray.insert(self?.searchTextField.text ?? "", at: 0)
-                    }
-                }
-                UserDefaults.standard.set(searchHistoryArray, forKey: "SearchHistoryArray")
-                
-                if let searchBlock = self?.searchBlock {
-                    searchBlock(self?.searchTextField.text ?? "")
-                }
-            }else {
-                SwiftProgressHUD.shared().showText("搜索内容不能为空")
-            }
-            
-            
-        }).disposed(by: disposeBag)
         
         cancelButton.rx.tap.subscribe(onNext: { [weak self] (data) in
             if let cancelBlock = self?.cancelBlock {
@@ -112,6 +87,7 @@ class SearchNavigationbarView: BaseView {
         searchTextField.font = kRegularFont14
         searchTextField.borderStyle = .none
         searchTextField.clearButtonMode = UITextField.ViewMode.whileEditing
+        searchTextField.delegate = self
         
         return searchTextField
     }()
@@ -124,3 +100,37 @@ class SearchNavigationbarView: BaseView {
     }()
     
 }
+
+extension SearchNavigationbarView : UITextFieldDelegate   {
+    
+    func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool {
+        textField.isSecureTextEntry = false
+        return true
+    }
+    func textFieldShouldReturn(_ textField: UITextField) -> Bool {
+        
+        if self.searchTextField.text?.count ?? 0 > 0 {
+            self.searchTextField.becomeFirstResponder()
+            
+            var searchHistoryArray = Array<String>()
+            
+            if UserDefaults.standard.array(forKey: "SearchHistoryArray")?.isEmpty ?? true {
+                searchHistoryArray.insert(self.searchTextField.text ?? "", at: 0)
+            } else {
+                searchHistoryArray = UserDefaults.standard.array(forKey: "SearchHistoryArray") as! [String]
+                if !(searchHistoryArray.contains(self.searchTextField.text ?? "")) {
+                    searchHistoryArray.insert(self.searchTextField.text ?? "", at: 0)
+                }
+            }
+            UserDefaults.standard.set(searchHistoryArray, forKey: "SearchHistoryArray")
+            
+            if let searchBlock = self.searchBlock {
+                searchBlock(self.searchTextField.text ?? "")
+            }
+        }else {
+            SwiftProgressHUD.shared().showText("搜索内容不能为空")
+        }
+        
+        return true
+    }
+}

+ 1 - 1
RainbowPlanet/RainbowPlanet/Modules/SearchModule/Search/View/SearchView.swift

@@ -36,7 +36,7 @@ class SearchView: BaseView {
         collectionView.ly_emptyView = emptyView
         collectionView.ly_startLoading()
         
-        guard UserDefaults.standard.array(forKey: "SearchHistoryArray")?.isEmpty ?? true else {
+        guard UserDefaults.standard.array(forKey: "SearchHistoryArray")?.isEmpty ?? true else { 
             searchHistoryArray = UserDefaults.standard.array(forKey: "SearchHistoryArray") as! [String]
             collectionView.reloadData()
             collectionView.ly_endLoading()

+ 4 - 4
RainbowPlanet/RainbowPlanet/Modules/SearchModule/Search/ViewController/SearchViewController.swift

@@ -28,9 +28,8 @@ class SearchViewController: BaseViewController {
     }
     
     override func setupViews() {
-        navigationBar.wr_setLeftButton(title: "", titleColor: UIColor.clear)
-        navigationBar.onClickLeftButton = nil
-        navigationBar.addSubview(navigationBarView)
+        navigationBar.isHidden = true
+        view.addSubview(navigationBarView)
         view.addSubview(searchView)
         view.insertSubview(navigationBar, aboveSubview: searchView)
     }
@@ -38,7 +37,8 @@ class SearchViewController: BaseViewController {
     override func setupLayouts() {
         navigationBarView.snp.makeConstraints { (make) in
             make.top.equalTo(kSafeStatusBarHeight)
-            make.bottom.left.right.equalToSuperview()
+            make.left.right.equalToSuperview()
+            make.height.equalTo(44)
         }
         searchView.snp.makeConstraints { (make) in
             make.top.equalTo(kNavBarTotalHeight)

+ 1 - 1
RainbowPlanet/RainbowPlanet/Modules/SearchModule/SearchContentList/ViewController/SearchContentListViewController.swift

@@ -18,7 +18,7 @@ class SearchContentListViewController: UIViewController {
     }
     weak var observe : NSObjectProtocol?
     
-    var keyWord : String = ""
+    var keyWord : String!
     var communityPostDataModels = Array<CommunityPostDataModel>()
     var heights = Array<CGFloat>()
     

+ 36 - 24
RainbowPlanet/RainbowPlanet/Modules/SearchModule/SearchResult/View/SearchResultNavigationbarView.swift

@@ -10,6 +10,11 @@ import UIKit
 import PPBadgeViewSwift
 
 class SearchResultNavigationbarView: BaseView {
+    
+        
+    deinit {
+        NXLLog("deinit")
+    }
 
     
     /// 返回
@@ -61,30 +66,6 @@ class SearchResultNavigationbarView: BaseView {
                 backBlock()
             }
         }).disposed(by: disposeBag)
-        
-        searchTextField.rx.controlEvent([.editingDidEndOnExit]).asObservable().subscribe(onNext: {  [weak self] (text) in
-            
-            if self?.searchTextField.text?.count ?? 0 > 0 {
-                self?.endEditing(true)
-                
-                var searchHistoryArray = Array<String>()
-                
-                if UserDefaults.standard.array(forKey: "SearchHistoryArray")?.isEmpty ?? true {
-                    searchHistoryArray.append(self?.searchTextField.text ?? "")
-                } else {
-                    searchHistoryArray = UserDefaults.standard.array(forKey: "SearchHistoryArray") as! [String]
-                    searchHistoryArray.append(self?.searchTextField.text ?? "")
-                }
-                UserDefaults.standard.set(searchHistoryArray, forKey: "SearchHistoryArray")
-                if let searchResultBlock = self?.searchResultBlock {
-                    searchResultBlock(self?.searchTextField.text ?? "")
-                }
-            }else {
-                SwiftProgressHUD.shared().showText("搜索商品不能为空")
-            }
-            
-            
-        }).disposed(by: disposeBag)
     }
     
     private lazy var backButton: UIButton = {
@@ -117,7 +98,38 @@ class SearchResultNavigationbarView: BaseView {
         searchTextField.font = kRegularFont14
         searchTextField.borderStyle = .none
         searchTextField.clearButtonMode = UITextField.ViewMode.whileEditing
+        searchTextField.delegate = self
         return searchTextField
     }()
+}
+
+extension SearchResultNavigationbarView : UITextFieldDelegate   {
+    
+    func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool {
+        textField.isSecureTextEntry = false
+        return true
+    }
     
+    func textFieldShouldReturn(_ textField: UITextField) -> Bool {
+        
+        if self.searchTextField.text?.count ?? 0 > 0 {
+            var searchHistoryArray = Array<String>()
+            self.searchTextField.becomeFirstResponder()
+            if UserDefaults.standard.array(forKey: "SearchHistoryArray")?.isEmpty ?? true {
+                searchHistoryArray.append(self.searchTextField.text ?? "")
+            } else {
+                searchHistoryArray = UserDefaults.standard.array(forKey: "SearchHistoryArray") as! [String]
+                searchHistoryArray.append(self.searchTextField.text ?? "")
+            }
+            UserDefaults.standard.set(searchHistoryArray, forKey: "SearchHistoryArray")
+            if let searchResultBlock = self.searchResultBlock {
+                searchResultBlock(self.searchTextField.text ?? "")
+            }
+        }else {
+            SwiftProgressHUD.shared().showText("搜索商品不能为空")
+        }
+        
+        return true
+    }
 }
+

+ 6 - 7
RainbowPlanet/RainbowPlanet/Modules/SearchModule/SearchResult/ViewController/SearchResultViewController.swift

@@ -17,9 +17,7 @@ class SearchResultViewController: BaseViewController {
     
     deinit {
         NXLLog("deinit")
-        if observe != nil {
-            NotificationCenter.default.removeObserver(observe!)
-        }
+        NotificationCenter.default.removeObserver(observe as Any)
     }
     weak var observe : NSObjectProtocol?
     
@@ -34,8 +32,9 @@ class SearchResultViewController: BaseViewController {
     }
     
     override func setupViews() {
-        navigationBar.leftButton.isHidden = true
-        navigationBar.addSubview(navigationBarView)
+        navigationBar.isHidden = true
+        navigationBarView.searchTextField.text = self.keyWord
+        view.addSubview(navigationBarView)
         view.addSubview(segmentedView)
         view.addSubview(listContainerView)
         
@@ -44,7 +43,8 @@ class SearchResultViewController: BaseViewController {
     override func setupLayouts() {
         navigationBarView.snp.makeConstraints { (make) in
             make.top.equalTo(kSafeStatusBarHeight)
-            make.bottom.left.right.equalToSuperview()
+            make.left.right.equalToSuperview()
+            make.height.equalTo(44)
         }
         
         segmentedView.snp.makeConstraints { (make) in
@@ -111,7 +111,6 @@ class SearchResultViewController: BaseViewController {
     
     private lazy var navigationBarView: SearchResultNavigationbarView = {
         let navigationBarView = SearchResultNavigationbarView()
-        navigationBarView.searchTextField.text = keyWord
         return navigationBarView
     }()
     

+ 5 - 2
RainbowPlanet/RainbowPlanet/Modules/SearchModule/SearchUser/View/SearchUserLitTableViewCell.swift

@@ -224,9 +224,12 @@ class SearchUserLitTableViewCell: UITableViewCell {
                 for i in 0..<(searchMemberModel?.followTopic?.count)! {
                     followTopic.append("#\(searchMemberModel?.followTopic![i] ?? "")")
                 }
+                let str = followTopic.joined(separator: " ")
+                topicLabel.text = str
+            }else {
+                topicLabel.text = "该用户未关注任何话题"
             }
-            let str = followTopic.joined(separator: " ")
-            topicLabel.text = str
+
             
             if searchMemberModel?.uid == UserModel.shared().getModel()?.uid {
                 followButton.isHidden = true

+ 1 - 1
RainbowPlanet/RainbowPlanet/Service/SwiftMoyaService/SwiftMoyaServiceApi/SwiftMoyaServiceCommunity/SwiftMoyaNetWorkServiceCommunity.swift

@@ -229,7 +229,7 @@ public class SwiftMoyaNetWorkServiceCommunity: NSObject {
         var parameters = Dictionary<String,Any>()
         parameters.updateValue(id, forKey: "id")
         parameters.updateValue(type, forKey: "type")
-        parameters.updateValue(topicId, forKey: "topicId")
+        parameters.updateValue(topicId, forKey: "topic_id")
         parameters.updateValue(page, forKey: "page")
         
         SwiftMoyaNetWorkManager.shared.requestObject(CommunityVideoListModel.self, target: MultiTarget(SwiftMoyaServiceCommunityApi.communityVideoList(parameters: parameters)), completion: { (communityVideoListModel) in

+ 1 - 1
RainbowPlanet/RainbowPlanet/Service/SwiftMoyaService/SwiftMoyaServiceApi/SwiftMoyaServiceUser/SwiftMoyaNetWorkServiceUser.swift

@@ -255,7 +255,7 @@ public class SwiftMoyaNetWorkServiceUser: NSObject {
             parameters.updateValue(umLoginModel.avatar, forKey: "avatar")
             parameters.updateValue(umLoginModel.username, forKey: "username")
             parameters.updateValue(umLoginModel.gender, forKey: "gender")
-            parameters.updateValue(umLoginModel.gender, forKey: "gender")
+            parameters.updateValue(loginType.rawValue, forKey: "login_type")
             
             
             SwiftMoyaNetWorkManager.shared.requestObject(UserModel.self,target: MultiTarget(SwiftMoyaServiceUserApi.userBindWeixin(parameters: parameters)), completion: { (userModel) in

+ 0 - 1
RainbowPlanet/RainbowPlanet/ViewModel/Community/CommunityFollowUserViewModel.swift

@@ -148,7 +148,6 @@ class CommunityFollowUserViewModel: NSObject {
             followButton.layer.borderColor = kThemeColor.cgColor
             followButton.layer.borderWidth = 0.5
             followButton.setBackgroundImage(UIImage.imageWithColor(color: kThemeColor), for: UIControl.State.normal)
-            followButton.isHidden = false
             break
         case .alreadyFollow:
             followButton.setTitle("已关注", for: UIControl.State.normal)