diff --git a/YouerLiveVideo/YouerLiveVideo.xcodeproj/project.pbxproj b/YouerLiveVideo/YouerLiveVideo.xcodeproj/project.pbxproj index b6c2434..083943f 100644 --- a/YouerLiveVideo/YouerLiveVideo.xcodeproj/project.pbxproj +++ b/YouerLiveVideo/YouerLiveVideo.xcodeproj/project.pbxproj @@ -589,8 +589,8 @@ BFBB83A81ECAE35E008B404B /* LeadViewController.swift */, 5904FC601ECA930D00E631FF /* MViewController.swift */, 5904FC431ECA8B8C00E631FF /* HomePage */, - 5904FC441ECA8B8C00E631FF /* MicroCourse */, 5904FC461ECA8B8C00E631FF /* Resource */, + 5904FC441ECA8B8C00E631FF /* MicroCourse */, 5904FC481ECA8B8C00E631FF /* TVStation */, BFBB83D81ECC445D008B404B /* User */, ); diff --git a/YouerLiveVideo/YouerLiveVideo/Base.lproj/Main.storyboard b/YouerLiveVideo/YouerLiveVideo/Base.lproj/Main.storyboard index 538d280..9258dd6 100644 --- a/YouerLiveVideo/YouerLiveVideo/Base.lproj/Main.storyboard +++ b/YouerLiveVideo/YouerLiveVideo/Base.lproj/Main.storyboard @@ -1,5 +1,5 @@ -<?xml version="1.0" encoding="UTF-8"?> -<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11762" systemVersion="16A323" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="fhe-aI-EYq"> +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11762" systemVersion="15G1217" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="fhe-aI-EYq"> <device id="retina4_7" orientation="portrait"> <adaptation id="fullscreen"/> </device> @@ -42,18 +42,57 @@ <rect key="frame" x="0.0" y="0.0" width="375" height="667"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <subviews> - <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="143" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="su6-Ve-Mu4"> + <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="za5-9d-anp"> + <rect key="frame" x="0.0" y="108" width="375" height="50"/> + <subviews> + <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text=" " textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="mgQ-3C-amN"> + <rect key="frame" x="8" y="16" width="4" height="18"/> + <fontDescription key="fontDescription" type="system" pointSize="15"/> + <nil key="textColor"/> + <nil key="highlightedColor"/> + </label> + <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="fz6-VO-SIi"> + <rect key="frame" x="310" y="10" width="57" height="30"/> + <constraints> + <constraint firstAttribute="height" constant="30" id="NCP-Ag-7c1"/> + </constraints> + <fontDescription key="fontDescription" type="system" pointSize="17"/> + <state key="normal" title="筛选" image="starLive"> + <color key="titleColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> + </state> + </button> + <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="a7C-jD-YSJ"> + <rect key="frame" x="245" y="14" width="57" height="22"/> + <fontDescription key="fontDescription" type="system" pointSize="17"/> + <state key="normal" title="排序" image="starLive"> + <color key="titleColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> + </state> + </button> + </subviews> + <color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/> + <constraints> + <constraint firstItem="fz6-VO-SIi" firstAttribute="leading" secondItem="a7C-jD-YSJ" secondAttribute="trailing" constant="8" id="AqG-KK-VAP"/> + <constraint firstItem="a7C-jD-YSJ" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="mgQ-3C-amN" secondAttribute="trailing" constant="8" id="HcO-bM-kZo"/> + <constraint firstAttribute="trailing" secondItem="fz6-VO-SIi" secondAttribute="trailing" constant="8" id="QzD-Ci-dUo"/> + <constraint firstItem="a7C-jD-YSJ" firstAttribute="centerY" secondItem="za5-9d-anp" secondAttribute="centerY" id="e22-SY-dro"/> + <constraint firstItem="fz6-VO-SIi" firstAttribute="centerY" secondItem="za5-9d-anp" secondAttribute="centerY" id="qBE-uD-fE1"/> + <constraint firstItem="mgQ-3C-amN" firstAttribute="centerY" secondItem="za5-9d-anp" secondAttribute="centerY" id="uMv-pj-P7r"/> + <constraint firstAttribute="height" constant="50" id="xiw-nW-gnr"/> + <constraint firstItem="mgQ-3C-amN" firstAttribute="leading" secondItem="za5-9d-anp" secondAttribute="leading" constant="8" id="yW6-qE-tfE"/> + </constraints> + </view> + <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="none" rowHeight="143" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="su6-Ve-Mu4"> <rect key="frame" x="0.0" y="158" width="375" height="460"/> <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/> <prototypes> - <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="cell" rowHeight="143" id="tO9-FG-1Ux" customClass="ResourceViewControllerTableViewCell" customModule="YouerLiveVideo" customModuleProvider="target"> + <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="identifier" rowHeight="143" id="tO9-FG-1Ux" customClass="ResourceViewControllerTableViewCell" customModule="YouerLiveVideo" customModuleProvider="target"> <rect key="frame" x="0.0" y="28" width="375" height="143"/> <autoresizingMask key="autoresizingMask"/> <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="tO9-FG-1Ux" id="73f-qf-61d"> - <rect key="frame" x="0.0" y="0.0" width="375" height="142"/> + <rect key="frame" x="0.0" y="0.0" width="375" height="143"/> <autoresizingMask key="autoresizingMask"/> <subviews> - <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="fqH-Ro-Yhh"> + <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="icon" translatesAutoresizingMaskIntoConstraints="NO" id="fqH-Ro-Yhh"> <rect key="frame" x="8" y="26.5" width="90" height="90"/> <constraints> <constraint firstAttribute="width" constant="90" id="1QK-QU-Ukp"/> @@ -80,6 +119,7 @@ </label> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="paA-9W-bbM"> <rect key="frame" x="325" y="90" width="42" height="21"/> + <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/> <fontDescription key="fontDescription" type="system" pointSize="17"/> <nil key="textColor"/> <nil key="highlightedColor"/> @@ -95,7 +135,7 @@ <color key="titleColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> </state> </button> - <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="ds9-Gw-nOf"> + <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="icon" translatesAutoresizingMaskIntoConstraints="NO" id="ds9-Gw-nOf"> <rect key="frame" x="297" y="90.5" width="20" height="20"/> <constraints> <constraint firstAttribute="width" secondItem="ds9-Gw-nOf" secondAttribute="height" multiplier="1:1" id="Mto-fo-vVR"/> @@ -120,6 +160,13 @@ <constraint firstAttribute="trailing" secondItem="yx0-8F-VaM" secondAttribute="trailing" constant="8" id="pBd-Lh-bTy"/> </constraints> </tableViewCellContentView> + <connections> + <outlet property="downLoadCountLabel" destination="paA-9W-bbM" id="JFm-xb-OgB"/> + <outlet property="iconImageView" destination="fqH-Ro-Yhh" id="LCb-Vi-esw"/> + <outlet property="timeLabel" destination="WIc-YL-RvX" id="Pfe-EP-np8"/> + <outlet property="titleLabel" destination="FNV-Qr-xrm" id="VMp-K4-fsA"/> + <outlet property="updateTeacherLabel" destination="IQj-VB-dch" id="Ivv-yb-r3K"/> + </connections> </tableViewCell> </prototypes> <connections> @@ -127,67 +174,77 @@ <outlet property="delegate" destination="xEc-U1-QCp" id="iof-1s-GH1"/> </connections> </tableView> - <searchBar contentMode="redraw" placeholder="搜索" translatesAutoresizingMaskIntoConstraints="NO" id="yoD-X2-JQ0"> + <view hidden="YES" alpha="0.29999999999999999" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="egd-vU-DWS"> + <rect key="frame" x="0.0" y="64" width="375" height="554"/> + <color key="backgroundColor" white="0.33333333333333331" alpha="1" colorSpace="calibratedWhite"/> + <gestureRecognizers/> + <connections> + <outletCollection property="gestureRecognizers" destination="uRc-MA-zeh" appends="YES" id="GEX-ck-vc6"/> + </connections> + </view> + <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="s32-SR-wby"> <rect key="frame" x="0.0" y="64" width="375" height="44"/> - <textInputTraits key="textInputTraits"/> - </searchBar> - <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="za5-9d-anp"> - <rect key="frame" x="0.0" y="108" width="375" height="50"/> - <subviews> - <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text=" " textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="mgQ-3C-amN"> - <rect key="frame" x="8" y="17" width="4" height="18"/> - <fontDescription key="fontDescription" type="system" pointSize="15"/> - <nil key="textColor"/> - <nil key="highlightedColor"/> - </label> - <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="fz6-VO-SIi"> - <rect key="frame" x="310" y="10" width="57" height="30"/> - <constraints> - <constraint firstAttribute="height" constant="30" id="NCP-Ag-7c1"/> - </constraints> - <fontDescription key="fontDescription" type="system" pointSize="17"/> - <state key="normal" title="筛选" image="starLive"> - <color key="titleColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> - </state> - </button> - <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="a7C-jD-YSJ"> - <rect key="frame" x="245" y="14" width="57" height="22"/> - <fontDescription key="fontDescription" type="system" pointSize="17"/> - <state key="normal" title="排序" image="starLive"> - <color key="titleColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> - </state> - </button> - </subviews> - <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> + <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/> <constraints> - <constraint firstItem="fz6-VO-SIi" firstAttribute="leading" secondItem="a7C-jD-YSJ" secondAttribute="trailing" constant="8" id="AqG-KK-VAP"/> - <constraint firstItem="a7C-jD-YSJ" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="mgQ-3C-amN" secondAttribute="trailing" constant="8" id="HcO-bM-kZo"/> - <constraint firstAttribute="trailing" secondItem="fz6-VO-SIi" secondAttribute="trailing" constant="8" id="QzD-Ci-dUo"/> - <constraint firstItem="a7C-jD-YSJ" firstAttribute="centerY" secondItem="za5-9d-anp" secondAttribute="centerY" id="e22-SY-dro"/> - <constraint firstItem="fz6-VO-SIi" firstAttribute="centerY" secondItem="za5-9d-anp" secondAttribute="centerY" id="qBE-uD-fE1"/> - <constraint firstItem="mgQ-3C-amN" firstAttribute="centerY" secondItem="za5-9d-anp" secondAttribute="centerY" id="uMv-pj-P7r"/> - <constraint firstAttribute="height" constant="50" id="xiw-nW-gnr"/> - <constraint firstItem="mgQ-3C-amN" firstAttribute="leading" secondItem="za5-9d-anp" secondAttribute="leading" constant="8" id="yW6-qE-tfE"/> + <constraint firstAttribute="height" constant="44" id="PWr-Wf-TcS"/> </constraints> - </view> + <prototypes> + <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="cell" id="vmV-r2-2pv"> + <rect key="frame" x="0.0" y="28" width="375" height="44"/> + <autoresizingMask key="autoresizingMask"/> + <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="vmV-r2-2pv" id="tft-RM-f2B"> + <rect key="frame" x="0.0" y="0.0" width="375" height="43"/> + <autoresizingMask key="autoresizingMask"/> + </tableViewCellContentView> + </tableViewCell> + </prototypes> + <connections> + <outlet property="dataSource" destination="xEc-U1-QCp" id="DTr-p1-Mg3"/> + <outlet property="delegate" destination="xEc-U1-QCp" id="i5j-LP-mOw"/> + </connections> + </tableView> </subviews> <color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/> <constraints> <constraint firstItem="isx-D9-RKA" firstAttribute="top" secondItem="su6-Ve-Mu4" secondAttribute="bottom" id="0dH-vT-0L7"/> - <constraint firstItem="yoD-X2-JQ0" firstAttribute="leading" secondItem="SdC-Ao-cee" secondAttribute="leading" id="2P3-aV-09x"/> - <constraint firstAttribute="trailing" secondItem="yoD-X2-JQ0" secondAttribute="trailing" id="3gn-Jp-76Y"/> <constraint firstAttribute="trailing" secondItem="su6-Ve-Mu4" secondAttribute="trailing" id="Bce-ui-FBr"/> <constraint firstItem="su6-Ve-Mu4" firstAttribute="top" secondItem="za5-9d-anp" secondAttribute="bottom" id="Cug-lI-DhS"/> - <constraint firstItem="za5-9d-anp" firstAttribute="top" secondItem="yoD-X2-JQ0" secondAttribute="bottom" id="Ine-er-3FG"/> + <constraint firstItem="s32-SR-wby" firstAttribute="leading" secondItem="SdC-Ao-cee" secondAttribute="leading" id="Czn-WH-v3b"/> + <constraint firstItem="isx-D9-RKA" firstAttribute="top" secondItem="egd-vU-DWS" secondAttribute="bottom" id="Rn7-2e-h0u"/> + <constraint firstItem="s32-SR-wby" firstAttribute="top" secondItem="vr1-kJ-xH9" secondAttribute="bottom" id="Sf7-iO-6Rj"/> <constraint firstAttribute="trailing" secondItem="za5-9d-anp" secondAttribute="trailing" id="VI2-tz-hSe"/> - <constraint firstItem="yoD-X2-JQ0" firstAttribute="top" secondItem="vr1-kJ-xH9" secondAttribute="bottom" id="XUd-hg-GGA"/> + <constraint firstItem="za5-9d-anp" firstAttribute="top" secondItem="vr1-kJ-xH9" secondAttribute="bottom" constant="44" id="WRE-71-5Hh"/> + <constraint firstAttribute="trailing" secondItem="s32-SR-wby" secondAttribute="trailing" id="ett-Tm-fVp"/> + <constraint firstItem="egd-vU-DWS" firstAttribute="top" secondItem="vr1-kJ-xH9" secondAttribute="bottom" id="gZk-Ki-TPv"/> + <constraint firstItem="egd-vU-DWS" firstAttribute="leading" secondItem="SdC-Ao-cee" secondAttribute="leading" id="ha6-oS-r9u"/> <constraint firstItem="za5-9d-anp" firstAttribute="leading" secondItem="SdC-Ao-cee" secondAttribute="leading" id="qdI-Q1-1Sk"/> + <constraint firstAttribute="trailing" secondItem="egd-vU-DWS" secondAttribute="trailing" id="rOV-OJ-vyb"/> <constraint firstItem="su6-Ve-Mu4" firstAttribute="leading" secondItem="SdC-Ao-cee" secondAttribute="leading" id="ydL-OO-314"/> </constraints> </view> <navigationItem key="navigationItem" id="fCE-jD-MLQ"/> + <connections> + <outlet property="grayView" destination="egd-vU-DWS" id="BJW-OO-Xca"/> + <outlet property="searchDisplayController" destination="k0q-9e-h1a" id="f1i-NC-WU2"/> + <outlet property="searchTableHeight" destination="PWr-Wf-TcS" id="0Yd-RL-DTU"/> + <outlet property="searchTableView" destination="s32-SR-wby" id="vTt-wv-fSR"/> + <outlet property="tableView" destination="su6-Ve-Mu4" id="NV5-ew-AZU"/> + </connections> </viewController> <placeholder placeholderIdentifier="IBFirstResponder" id="ksp-rg-C8h" userLabel="First Responder" sceneMemberID="firstResponder"/> + <searchDisplayController id="k0q-9e-h1a"> + <connections> + <outlet property="delegate" destination="xEc-U1-QCp" id="Jvw-1T-APb"/> + <outlet property="searchContentsController" destination="xEc-U1-QCp" id="h4V-2A-Qlt"/> + <outlet property="searchResultsDataSource" destination="xEc-U1-QCp" id="SkR-0A-41I"/> + <outlet property="searchResultsDelegate" destination="xEc-U1-QCp" id="qPU-va-8W5"/> + </connections> + </searchDisplayController> + <tapGestureRecognizer id="uRc-MA-zeh"> + <connections> + <action selector="cancleSearchActivit:" destination="xEc-U1-QCp" id="UEb-89-R10"/> + </connections> + </tapGestureRecognizer> </objects> <point key="canvasLocation" x="-1084" y="2112.5937031484259"/> </scene> diff --git a/YouerLiveVideo/YouerLiveVideo/controllers/Resource/ResourceViewController.swift b/YouerLiveVideo/YouerLiveVideo/controllers/Resource/ResourceViewController.swift index 6ed4a64..b5fac17 100644 --- a/YouerLiveVideo/YouerLiveVideo/controllers/Resource/ResourceViewController.swift +++ b/YouerLiveVideo/YouerLiveVideo/controllers/Resource/ResourceViewController.swift @@ -8,47 +8,153 @@ import UIKit -class ResourceViewController: UIViewController { - +class ResourceViewController: UIViewController,UITableViewDelegate,UITableViewDataSource,UISearchControllerDelegate,UISearchResultsUpdating { + @IBOutlet var tableView: UITableView! + + @IBOutlet var grayView: UIView! + @IBOutlet var searchTableView: UITableView! + @IBOutlet var searchTableHeight: NSLayoutConstraint! + + var searchController:UISearchController! + var dataSetAry:[String]=["葛建军","张道峰","徐晓杰","左承","段合江"] + var searchAry:[String]=[] + var currentPage:Int=0 //当前页数,每次取十个数据 + var resourceData:[MicroCourseModel]=[] override func viewDidLoad() { super.viewDidLoad() self.configTheme() - // Do any additional setup after loading the view. + addSearchController() + addRefresh() + self.refreshLivesAction(tag: self.currentPage, completionHandler: { (success) in + if success{ + self.tableView.reloadData() + } + }) } - - override func didReceiveMemoryWarning() { - super.didReceiveMemoryWarning() - // Dispose of any resources that can be recreated. + func addSearchController(){ + self.definesPresentationContext=true + searchController=UISearchController(searchResultsController: nil) + searchController.delegate=self + searchController.searchResultsUpdater=self + searchController.searchBar.barTintColor=UIColor.groupTableViewBackground + searchController.searchBar.placeholder="搜索" + //设置UISearchController的显示属性,以下3个属性默认为YES + //搜索时,背景变暗色 + self.searchController.dimsBackgroundDuringPresentation=false + //搜索时,背景变模糊 + // self.searchController.obscuresBackgroundDuringPresentation=false + //点击搜索的时候,是否隐藏导航栏 + // searchController.hidesNavigationBarDuringPresentation=true + //位置 + searchController.searchBar.frame=CGRect(x: self.searchController.searchBar.frame.origin.x, y: self.searchController.searchBar.frame.origin.y, width: self.searchController.searchBar.frame.size.width, height: 44.0); + // self.view.addSubview(searchController.searchBar) + searchTableView.tableHeaderView=searchController.searchBar } - - - /* - // MARK: - Navigation - - // In a storyboard-based application, you will often want to do a little preparation before navigation - override func prepare(for segue: UIStoryboardSegue, sender: Any?) { - // Get the new view controller using segue.destinationViewController. - // Pass the selected object to the new view controller. + func addRefresh(){ + let header=MJRefreshNormalHeader(refreshingBlock: { + //下拉刷新 + self.currentPage=0 + self.resourceData.removeAll() + self.refreshLivesAction(tag: self.currentPage, completionHandler: { (success) in + if success{ + self.tableView.reloadData() + } + self.tableView.mj_header.endRefreshing() + }) + }) + header?.lastUpdatedTimeLabel.isHidden=true + tableView.mj_header=header + tableView.mj_footer=MJRefreshBackNormalFooter(refreshingBlock: { + //上拉加载更多 + self.refreshLivesAction(tag: self.currentPage, completionHandler: { (success) in + if success{ + self.tableView.reloadData() + } + self.tableView.mj_footer.endRefreshing() + }) + }) + } + // MARK: - 刷新数据接口 + func refreshLivesAction(tag:Int,completionHandler:@escaping (Bool) -> ()){ + let parameters:Dictionary<String,AnyObject>=["type":1 as AnyObject,"pageIndex":tag as AnyObject,"pageSize":1 as AnyObject] + AppDelegate.instance().httpServer.getHotRescourse(parameters: parameters) { (str, error) in + var success:Bool=true + if error==nil { + if JSON.fromString(jsonString: str)!["status"].intValue == 1{ + httpJsonResule(jsonString: str, error: error, successHandler: { (json) in + if JSON.fromString(jsonString: str)!["data"].arrayValue.count>0{ + self.currentPage+=1 + } + for item in JSON.fromString(jsonString: str)!["data"].arrayValue { + self.resourceData.append(MicroCourseModel(j: item)) + } + success=true + }, failHandler: { (error) in + success=false + appRootViewController().view.makeToast("获取资源失败:\(error.localizedDescription)") + }) + }else{ + success=false + appRootViewController().view.makeToast("获取资源失败:\(JSON.fromString(jsonString: str)!["message"].stringValue)") + } + }else{ + success=false + appRootViewController().view.makeToast("获取资源失败:\(error!.description)") + } + completionHandler(success) + } } - */ - -} - -extension ResourceViewController:UITableViewDelegate,UITableViewDataSource{ func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - return 10 + if tableView==searchTableView{ + return searchAry.count + }else{ + return resourceData.count + } + } + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + if tableView==searchTableView { + let cell=tableView.dequeueReusableCell(withIdentifier: "cell") + cell?.textLabel?.text=searchAry[indexPath.row] + return cell! + }else{ + let cell=tableView.dequeueReusableCell(withIdentifier: "identifier") as! ResourceViewControllerTableViewCell + cell.setUpWith(item: resourceData[indexPath.row]) + return cell + } } - func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { - + if tableView==searchTableView { + let vc = UIStoryboard(name: "HomePage", bundle: nil).instantiateViewController(withIdentifier: "RankingTableViewController") as! RankingTableViewController + self.navigationController?.pushViewController(vc, animated: true) + } } - - func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { - let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! ResourceViewControllerTableViewCell - return cell + //取消键盘输入状态 + @IBAction func cancleSearchActivit(_ sender: UITapGestureRecognizer) { + searchController.isActive=false + } + func willPresentSearchController(_ searchController: UISearchController) { + grayView.isHidden=false } + func willDismissSearchController(_ searchController: UISearchController) { + searchTableHeight.constant=44 + grayView.isHidden=true + } + //谓词搜索过滤 + func updateSearchResults(for searchController: UISearchController) { + let searchString=searchController.searchBar.text + let predicate=NSPredicate(format: "SELF CONTAINS[c] %@", searchString!) + searchAry=(dataSetAry as NSArray).filtered(using: predicate) as! [String] + if CGFloat((searchAry.count+1)*44)>(getScreenHeight()-64){ + searchTableHeight.constant=getScreenHeight()-64 + }else{ + searchTableHeight.constant=CGFloat((searchAry.count+1)*44) + } + searchTableView.reloadData() + } + } + extension ResourceViewController:UICollectionViewDelegate,UICollectionViewDelegateFlowLayout,UICollectionViewDataSource{ func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { @@ -66,7 +172,18 @@ extension ResourceViewController:UICollectionViewDelegate,UICollectionViewDelega } class ResourceViewControllerTableViewCell:UITableViewCell{ - + @IBOutlet var iconImageView: UIImageView! + @IBOutlet var titleLabel: UILabel! + @IBOutlet var updateTeacherLabel: UILabel! + @IBOutlet var timeLabel: UILabel! + @IBOutlet var downLoadCountLabel: UILabel! + func setUpWith(item: MicroCourseModel){ + iconImageView.sd_setImage(with: URL(string: item.f_Img), placeholderImage: UIImage(named: "icon_course_placeholder")) + titleLabel.text=item.f_Title + updateTeacherLabel.text="上传者:\(item.f_CreatorName) 老师" + timeLabel.text=item.f_CreatorTime + downLoadCountLabel.text="\(item.f_DownloadSum)" + } } diff --git a/YouerLiveVideo/YouerLiveVideo/util/utiles.swift b/YouerLiveVideo/YouerLiveVideo/util/utiles.swift index f96d3bb..939dffe 100644 --- a/YouerLiveVideo/YouerLiveVideo/util/utiles.swift +++ b/YouerLiveVideo/YouerLiveVideo/util/utiles.swift @@ -49,7 +49,7 @@ class AlertController { } class Theme{ static func topBarColor()->UIColor{ - return UIColorFromRGB(0xff6533)//UIColorFromRGB(0xff9b34)f6595f + return UIColorFromRGB(0x1CA2FF)//UIColorFromRGB(0xff9b34)f6595f } ///按钮样式 static func configButton(_ button:UIButton){ -- libgit2 0.21.0