Commit 5b0c5e90f6aeebf9ea986ec5338da395e74ac31f

Authored by 葛建军
1 parent 0db1c538
Exists in newLive

资源首页数据填充

YouerLiveVideo/YouerLiveVideo.xcodeproj/project.pbxproj
... ... @@ -589,8 +589,8 @@
589 589 BFBB83A81ECAE35E008B404B /* LeadViewController.swift */,
590 590 5904FC601ECA930D00E631FF /* MViewController.swift */,
591 591 5904FC431ECA8B8C00E631FF /* HomePage */,
592   - 5904FC441ECA8B8C00E631FF /* MicroCourse */,
593 592 5904FC461ECA8B8C00E631FF /* Resource */,
  593 + 5904FC441ECA8B8C00E631FF /* MicroCourse */,
594 594 5904FC481ECA8B8C00E631FF /* TVStation */,
595 595 BFBB83D81ECC445D008B404B /* User */,
596 596 );
... ...
YouerLiveVideo/YouerLiveVideo/Base.lproj/Main.storyboard
1   -<?xml version="1.0" encoding="UTF-8"?>
2   -<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">
  1 +<?xml version="1.0" encoding="UTF-8" standalone="no"?>
  2 +<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">
3 3 <device id="retina4_7" orientation="portrait">
4 4 <adaptation id="fullscreen"/>
5 5 </device>
... ... @@ -42,18 +42,57 @@
42 42 <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
43 43 <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
44 44 <subviews>
45   - <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">
  45 + <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="za5-9d-anp">
  46 + <rect key="frame" x="0.0" y="108" width="375" height="50"/>
  47 + <subviews>
  48 + <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">
  49 + <rect key="frame" x="8" y="16" width="4" height="18"/>
  50 + <fontDescription key="fontDescription" type="system" pointSize="15"/>
  51 + <nil key="textColor"/>
  52 + <nil key="highlightedColor"/>
  53 + </label>
  54 + <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="fz6-VO-SIi">
  55 + <rect key="frame" x="310" y="10" width="57" height="30"/>
  56 + <constraints>
  57 + <constraint firstAttribute="height" constant="30" id="NCP-Ag-7c1"/>
  58 + </constraints>
  59 + <fontDescription key="fontDescription" type="system" pointSize="17"/>
  60 + <state key="normal" title="筛选" image="starLive">
  61 + <color key="titleColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
  62 + </state>
  63 + </button>
  64 + <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="a7C-jD-YSJ">
  65 + <rect key="frame" x="245" y="14" width="57" height="22"/>
  66 + <fontDescription key="fontDescription" type="system" pointSize="17"/>
  67 + <state key="normal" title="排序" image="starLive">
  68 + <color key="titleColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
  69 + </state>
  70 + </button>
  71 + </subviews>
  72 + <color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
  73 + <constraints>
  74 + <constraint firstItem="fz6-VO-SIi" firstAttribute="leading" secondItem="a7C-jD-YSJ" secondAttribute="trailing" constant="8" id="AqG-KK-VAP"/>
  75 + <constraint firstItem="a7C-jD-YSJ" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="mgQ-3C-amN" secondAttribute="trailing" constant="8" id="HcO-bM-kZo"/>
  76 + <constraint firstAttribute="trailing" secondItem="fz6-VO-SIi" secondAttribute="trailing" constant="8" id="QzD-Ci-dUo"/>
  77 + <constraint firstItem="a7C-jD-YSJ" firstAttribute="centerY" secondItem="za5-9d-anp" secondAttribute="centerY" id="e22-SY-dro"/>
  78 + <constraint firstItem="fz6-VO-SIi" firstAttribute="centerY" secondItem="za5-9d-anp" secondAttribute="centerY" id="qBE-uD-fE1"/>
  79 + <constraint firstItem="mgQ-3C-amN" firstAttribute="centerY" secondItem="za5-9d-anp" secondAttribute="centerY" id="uMv-pj-P7r"/>
  80 + <constraint firstAttribute="height" constant="50" id="xiw-nW-gnr"/>
  81 + <constraint firstItem="mgQ-3C-amN" firstAttribute="leading" secondItem="za5-9d-anp" secondAttribute="leading" constant="8" id="yW6-qE-tfE"/>
  82 + </constraints>
  83 + </view>
  84 + <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">
46 85 <rect key="frame" x="0.0" y="158" width="375" height="460"/>
47 86 <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
48 87 <prototypes>
49   - <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="cell" rowHeight="143" id="tO9-FG-1Ux" customClass="ResourceViewControllerTableViewCell" customModule="YouerLiveVideo" customModuleProvider="target">
  88 + <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="identifier" rowHeight="143" id="tO9-FG-1Ux" customClass="ResourceViewControllerTableViewCell" customModule="YouerLiveVideo" customModuleProvider="target">
50 89 <rect key="frame" x="0.0" y="28" width="375" height="143"/>
51 90 <autoresizingMask key="autoresizingMask"/>
52 91 <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="tO9-FG-1Ux" id="73f-qf-61d">
53   - <rect key="frame" x="0.0" y="0.0" width="375" height="142"/>
  92 + <rect key="frame" x="0.0" y="0.0" width="375" height="143"/>
54 93 <autoresizingMask key="autoresizingMask"/>
55 94 <subviews>
56   - <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="fqH-Ro-Yhh">
  95 + <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="icon" translatesAutoresizingMaskIntoConstraints="NO" id="fqH-Ro-Yhh">
57 96 <rect key="frame" x="8" y="26.5" width="90" height="90"/>
58 97 <constraints>
59 98 <constraint firstAttribute="width" constant="90" id="1QK-QU-Ukp"/>
... ... @@ -80,6 +119,7 @@
80 119 </label>
81 120 <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">
82 121 <rect key="frame" x="325" y="90" width="42" height="21"/>
  122 + <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
83 123 <fontDescription key="fontDescription" type="system" pointSize="17"/>
84 124 <nil key="textColor"/>
85 125 <nil key="highlightedColor"/>
... ... @@ -95,7 +135,7 @@
95 135 <color key="titleColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
96 136 </state>
97 137 </button>
98   - <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="ds9-Gw-nOf">
  138 + <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="icon" translatesAutoresizingMaskIntoConstraints="NO" id="ds9-Gw-nOf">
99 139 <rect key="frame" x="297" y="90.5" width="20" height="20"/>
100 140 <constraints>
101 141 <constraint firstAttribute="width" secondItem="ds9-Gw-nOf" secondAttribute="height" multiplier="1:1" id="Mto-fo-vVR"/>
... ... @@ -120,6 +160,13 @@
120 160 <constraint firstAttribute="trailing" secondItem="yx0-8F-VaM" secondAttribute="trailing" constant="8" id="pBd-Lh-bTy"/>
121 161 </constraints>
122 162 </tableViewCellContentView>
  163 + <connections>
  164 + <outlet property="downLoadCountLabel" destination="paA-9W-bbM" id="JFm-xb-OgB"/>
  165 + <outlet property="iconImageView" destination="fqH-Ro-Yhh" id="LCb-Vi-esw"/>
  166 + <outlet property="timeLabel" destination="WIc-YL-RvX" id="Pfe-EP-np8"/>
  167 + <outlet property="titleLabel" destination="FNV-Qr-xrm" id="VMp-K4-fsA"/>
  168 + <outlet property="updateTeacherLabel" destination="IQj-VB-dch" id="Ivv-yb-r3K"/>
  169 + </connections>
123 170 </tableViewCell>
124 171 </prototypes>
125 172 <connections>
... ... @@ -127,67 +174,77 @@
127 174 <outlet property="delegate" destination="xEc-U1-QCp" id="iof-1s-GH1"/>
128 175 </connections>
129 176 </tableView>
130   - <searchBar contentMode="redraw" placeholder="搜索" translatesAutoresizingMaskIntoConstraints="NO" id="yoD-X2-JQ0">
  177 + <view hidden="YES" alpha="0.29999999999999999" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="egd-vU-DWS">
  178 + <rect key="frame" x="0.0" y="64" width="375" height="554"/>
  179 + <color key="backgroundColor" white="0.33333333333333331" alpha="1" colorSpace="calibratedWhite"/>
  180 + <gestureRecognizers/>
  181 + <connections>
  182 + <outletCollection property="gestureRecognizers" destination="uRc-MA-zeh" appends="YES" id="GEX-ck-vc6"/>
  183 + </connections>
  184 + </view>
  185 + <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">
131 186 <rect key="frame" x="0.0" y="64" width="375" height="44"/>
132   - <textInputTraits key="textInputTraits"/>
133   - </searchBar>
134   - <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="za5-9d-anp">
135   - <rect key="frame" x="0.0" y="108" width="375" height="50"/>
136   - <subviews>
137   - <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">
138   - <rect key="frame" x="8" y="17" width="4" height="18"/>
139   - <fontDescription key="fontDescription" type="system" pointSize="15"/>
140   - <nil key="textColor"/>
141   - <nil key="highlightedColor"/>
142   - </label>
143   - <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="fz6-VO-SIi">
144   - <rect key="frame" x="310" y="10" width="57" height="30"/>
145   - <constraints>
146   - <constraint firstAttribute="height" constant="30" id="NCP-Ag-7c1"/>
147   - </constraints>
148   - <fontDescription key="fontDescription" type="system" pointSize="17"/>
149   - <state key="normal" title="筛选" image="starLive">
150   - <color key="titleColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
151   - </state>
152   - </button>
153   - <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="a7C-jD-YSJ">
154   - <rect key="frame" x="245" y="14" width="57" height="22"/>
155   - <fontDescription key="fontDescription" type="system" pointSize="17"/>
156   - <state key="normal" title="排序" image="starLive">
157   - <color key="titleColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
158   - </state>
159   - </button>
160   - </subviews>
161   - <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
  187 + <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
162 188 <constraints>
163   - <constraint firstItem="fz6-VO-SIi" firstAttribute="leading" secondItem="a7C-jD-YSJ" secondAttribute="trailing" constant="8" id="AqG-KK-VAP"/>
164   - <constraint firstItem="a7C-jD-YSJ" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="mgQ-3C-amN" secondAttribute="trailing" constant="8" id="HcO-bM-kZo"/>
165   - <constraint firstAttribute="trailing" secondItem="fz6-VO-SIi" secondAttribute="trailing" constant="8" id="QzD-Ci-dUo"/>
166   - <constraint firstItem="a7C-jD-YSJ" firstAttribute="centerY" secondItem="za5-9d-anp" secondAttribute="centerY" id="e22-SY-dro"/>
167   - <constraint firstItem="fz6-VO-SIi" firstAttribute="centerY" secondItem="za5-9d-anp" secondAttribute="centerY" id="qBE-uD-fE1"/>
168   - <constraint firstItem="mgQ-3C-amN" firstAttribute="centerY" secondItem="za5-9d-anp" secondAttribute="centerY" id="uMv-pj-P7r"/>
169   - <constraint firstAttribute="height" constant="50" id="xiw-nW-gnr"/>
170   - <constraint firstItem="mgQ-3C-amN" firstAttribute="leading" secondItem="za5-9d-anp" secondAttribute="leading" constant="8" id="yW6-qE-tfE"/>
  189 + <constraint firstAttribute="height" constant="44" id="PWr-Wf-TcS"/>
171 190 </constraints>
172   - </view>
  191 + <prototypes>
  192 + <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="cell" id="vmV-r2-2pv">
  193 + <rect key="frame" x="0.0" y="28" width="375" height="44"/>
  194 + <autoresizingMask key="autoresizingMask"/>
  195 + <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="vmV-r2-2pv" id="tft-RM-f2B">
  196 + <rect key="frame" x="0.0" y="0.0" width="375" height="43"/>
  197 + <autoresizingMask key="autoresizingMask"/>
  198 + </tableViewCellContentView>
  199 + </tableViewCell>
  200 + </prototypes>
  201 + <connections>
  202 + <outlet property="dataSource" destination="xEc-U1-QCp" id="DTr-p1-Mg3"/>
  203 + <outlet property="delegate" destination="xEc-U1-QCp" id="i5j-LP-mOw"/>
  204 + </connections>
  205 + </tableView>
173 206 </subviews>
174 207 <color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
175 208 <constraints>
176 209 <constraint firstItem="isx-D9-RKA" firstAttribute="top" secondItem="su6-Ve-Mu4" secondAttribute="bottom" id="0dH-vT-0L7"/>
177   - <constraint firstItem="yoD-X2-JQ0" firstAttribute="leading" secondItem="SdC-Ao-cee" secondAttribute="leading" id="2P3-aV-09x"/>
178   - <constraint firstAttribute="trailing" secondItem="yoD-X2-JQ0" secondAttribute="trailing" id="3gn-Jp-76Y"/>
179 210 <constraint firstAttribute="trailing" secondItem="su6-Ve-Mu4" secondAttribute="trailing" id="Bce-ui-FBr"/>
180 211 <constraint firstItem="su6-Ve-Mu4" firstAttribute="top" secondItem="za5-9d-anp" secondAttribute="bottom" id="Cug-lI-DhS"/>
181   - <constraint firstItem="za5-9d-anp" firstAttribute="top" secondItem="yoD-X2-JQ0" secondAttribute="bottom" id="Ine-er-3FG"/>
  212 + <constraint firstItem="s32-SR-wby" firstAttribute="leading" secondItem="SdC-Ao-cee" secondAttribute="leading" id="Czn-WH-v3b"/>
  213 + <constraint firstItem="isx-D9-RKA" firstAttribute="top" secondItem="egd-vU-DWS" secondAttribute="bottom" id="Rn7-2e-h0u"/>
  214 + <constraint firstItem="s32-SR-wby" firstAttribute="top" secondItem="vr1-kJ-xH9" secondAttribute="bottom" id="Sf7-iO-6Rj"/>
182 215 <constraint firstAttribute="trailing" secondItem="za5-9d-anp" secondAttribute="trailing" id="VI2-tz-hSe"/>
183   - <constraint firstItem="yoD-X2-JQ0" firstAttribute="top" secondItem="vr1-kJ-xH9" secondAttribute="bottom" id="XUd-hg-GGA"/>
  216 + <constraint firstItem="za5-9d-anp" firstAttribute="top" secondItem="vr1-kJ-xH9" secondAttribute="bottom" constant="44" id="WRE-71-5Hh"/>
  217 + <constraint firstAttribute="trailing" secondItem="s32-SR-wby" secondAttribute="trailing" id="ett-Tm-fVp"/>
  218 + <constraint firstItem="egd-vU-DWS" firstAttribute="top" secondItem="vr1-kJ-xH9" secondAttribute="bottom" id="gZk-Ki-TPv"/>
  219 + <constraint firstItem="egd-vU-DWS" firstAttribute="leading" secondItem="SdC-Ao-cee" secondAttribute="leading" id="ha6-oS-r9u"/>
184 220 <constraint firstItem="za5-9d-anp" firstAttribute="leading" secondItem="SdC-Ao-cee" secondAttribute="leading" id="qdI-Q1-1Sk"/>
  221 + <constraint firstAttribute="trailing" secondItem="egd-vU-DWS" secondAttribute="trailing" id="rOV-OJ-vyb"/>
185 222 <constraint firstItem="su6-Ve-Mu4" firstAttribute="leading" secondItem="SdC-Ao-cee" secondAttribute="leading" id="ydL-OO-314"/>
186 223 </constraints>
187 224 </view>
188 225 <navigationItem key="navigationItem" id="fCE-jD-MLQ"/>
  226 + <connections>
  227 + <outlet property="grayView" destination="egd-vU-DWS" id="BJW-OO-Xca"/>
  228 + <outlet property="searchDisplayController" destination="k0q-9e-h1a" id="f1i-NC-WU2"/>
  229 + <outlet property="searchTableHeight" destination="PWr-Wf-TcS" id="0Yd-RL-DTU"/>
  230 + <outlet property="searchTableView" destination="s32-SR-wby" id="vTt-wv-fSR"/>
  231 + <outlet property="tableView" destination="su6-Ve-Mu4" id="NV5-ew-AZU"/>
  232 + </connections>
189 233 </viewController>
190 234 <placeholder placeholderIdentifier="IBFirstResponder" id="ksp-rg-C8h" userLabel="First Responder" sceneMemberID="firstResponder"/>
  235 + <searchDisplayController id="k0q-9e-h1a">
  236 + <connections>
  237 + <outlet property="delegate" destination="xEc-U1-QCp" id="Jvw-1T-APb"/>
  238 + <outlet property="searchContentsController" destination="xEc-U1-QCp" id="h4V-2A-Qlt"/>
  239 + <outlet property="searchResultsDataSource" destination="xEc-U1-QCp" id="SkR-0A-41I"/>
  240 + <outlet property="searchResultsDelegate" destination="xEc-U1-QCp" id="qPU-va-8W5"/>
  241 + </connections>
  242 + </searchDisplayController>
  243 + <tapGestureRecognizer id="uRc-MA-zeh">
  244 + <connections>
  245 + <action selector="cancleSearchActivit:" destination="xEc-U1-QCp" id="UEb-89-R10"/>
  246 + </connections>
  247 + </tapGestureRecognizer>
191 248 </objects>
192 249 <point key="canvasLocation" x="-1084" y="2112.5937031484259"/>
193 250 </scene>
... ...
YouerLiveVideo/YouerLiveVideo/controllers/Resource/ResourceViewController.swift
... ... @@ -8,47 +8,153 @@
8 8  
9 9 import UIKit
10 10  
11   -class ResourceViewController: UIViewController {
12   -
  11 +class ResourceViewController: UIViewController,UITableViewDelegate,UITableViewDataSource,UISearchControllerDelegate,UISearchResultsUpdating {
  12 + @IBOutlet var tableView: UITableView!
  13 +
  14 + @IBOutlet var grayView: UIView!
  15 + @IBOutlet var searchTableView: UITableView!
  16 + @IBOutlet var searchTableHeight: NSLayoutConstraint!
  17 +
  18 + var searchController:UISearchController!
  19 + var dataSetAry:[String]=["葛建军","张道峰","徐晓杰","左承","段合江"]
  20 + var searchAry:[String]=[]
  21 + var currentPage:Int=0 //当前页数,每次取十个数据
  22 + var resourceData:[MicroCourseModel]=[]
13 23 override func viewDidLoad() {
14 24 super.viewDidLoad()
15 25 self.configTheme()
16   - // Do any additional setup after loading the view.
  26 + addSearchController()
  27 + addRefresh()
  28 + self.refreshLivesAction(tag: self.currentPage, completionHandler: { (success) in
  29 + if success{
  30 + self.tableView.reloadData()
  31 + }
  32 + })
17 33 }
18   -
19   - override func didReceiveMemoryWarning() {
20   - super.didReceiveMemoryWarning()
21   - // Dispose of any resources that can be recreated.
  34 + func addSearchController(){
  35 + self.definesPresentationContext=true
  36 + searchController=UISearchController(searchResultsController: nil)
  37 + searchController.delegate=self
  38 + searchController.searchResultsUpdater=self
  39 + searchController.searchBar.barTintColor=UIColor.groupTableViewBackground
  40 + searchController.searchBar.placeholder="搜索"
  41 + //设置UISearchController的显示属性,以下3个属性默认为YES
  42 + //搜索时,背景变暗色
  43 + self.searchController.dimsBackgroundDuringPresentation=false
  44 + //搜索时,背景变模糊
  45 + // self.searchController.obscuresBackgroundDuringPresentation=false
  46 + //点击搜索的时候,是否隐藏导航栏
  47 + // searchController.hidesNavigationBarDuringPresentation=true
  48 + //位置
  49 + 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);
  50 + // self.view.addSubview(searchController.searchBar)
  51 + searchTableView.tableHeaderView=searchController.searchBar
22 52 }
23   -
24   -
25   - /*
26   - // MARK: - Navigation
27   -
28   - // In a storyboard-based application, you will often want to do a little preparation before navigation
29   - override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
30   - // Get the new view controller using segue.destinationViewController.
31   - // Pass the selected object to the new view controller.
  53 + func addRefresh(){
  54 + let header=MJRefreshNormalHeader(refreshingBlock: {
  55 + //下拉刷新
  56 + self.currentPage=0
  57 + self.resourceData.removeAll()
  58 + self.refreshLivesAction(tag: self.currentPage, completionHandler: { (success) in
  59 + if success{
  60 + self.tableView.reloadData()
  61 + }
  62 + self.tableView.mj_header.endRefreshing()
  63 + })
  64 + })
  65 + header?.lastUpdatedTimeLabel.isHidden=true
  66 + tableView.mj_header=header
  67 + tableView.mj_footer=MJRefreshBackNormalFooter(refreshingBlock: {
  68 + //上拉加载更多
  69 + self.refreshLivesAction(tag: self.currentPage, completionHandler: { (success) in
  70 + if success{
  71 + self.tableView.reloadData()
  72 + }
  73 + self.tableView.mj_footer.endRefreshing()
  74 + })
  75 + })
  76 + }
  77 + // MARK: - 刷新数据接口
  78 + func refreshLivesAction(tag:Int,completionHandler:@escaping (Bool) -> ()){
  79 + let parameters:Dictionary<String,AnyObject>=["type":1 as AnyObject,"pageIndex":tag as AnyObject,"pageSize":1 as AnyObject]
  80 + AppDelegate.instance().httpServer.getHotRescourse(parameters: parameters) { (str, error) in
  81 + var success:Bool=true
  82 + if error==nil {
  83 + if JSON.fromString(jsonString: str)!["status"].intValue == 1{
  84 + httpJsonResule(jsonString: str, error: error, successHandler: { (json) in
  85 + if JSON.fromString(jsonString: str)!["data"].arrayValue.count>0{
  86 + self.currentPage+=1
  87 + }
  88 + for item in JSON.fromString(jsonString: str)!["data"].arrayValue {
  89 + self.resourceData.append(MicroCourseModel(j: item))
  90 + }
  91 + success=true
  92 + }, failHandler: { (error) in
  93 + success=false
  94 + appRootViewController().view.makeToast("获取资源失败:\(error.localizedDescription)")
  95 + })
  96 + }else{
  97 + success=false
  98 + appRootViewController().view.makeToast("获取资源失败:\(JSON.fromString(jsonString: str)!["message"].stringValue)")
  99 + }
  100 + }else{
  101 + success=false
  102 + appRootViewController().view.makeToast("获取资源失败:\(error!.description)")
  103 + }
  104 + completionHandler(success)
  105 + }
32 106 }
33   - */
34   -
35   -}
36   -
37   -extension ResourceViewController:UITableViewDelegate,UITableViewDataSource{
38 107 func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
39   - return 10
  108 + if tableView==searchTableView{
  109 + return searchAry.count
  110 + }else{
  111 + return resourceData.count
  112 + }
  113 + }
  114 + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  115 + if tableView==searchTableView {
  116 + let cell=tableView.dequeueReusableCell(withIdentifier: "cell")
  117 + cell?.textLabel?.text=searchAry[indexPath.row]
  118 + return cell!
  119 + }else{
  120 + let cell=tableView.dequeueReusableCell(withIdentifier: "identifier") as! ResourceViewControllerTableViewCell
  121 + cell.setUpWith(item: resourceData[indexPath.row])
  122 + return cell
  123 + }
40 124 }
41   -
42 125 func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
43   -
  126 + if tableView==searchTableView {
  127 + let vc = UIStoryboard(name: "HomePage", bundle: nil).instantiateViewController(withIdentifier: "RankingTableViewController") as! RankingTableViewController
  128 + self.navigationController?.pushViewController(vc, animated: true)
  129 + }
44 130 }
45   -
46   - func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
47   - let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! ResourceViewControllerTableViewCell
48   - return cell
  131 + //取消键盘输入状态
  132 + @IBAction func cancleSearchActivit(_ sender: UITapGestureRecognizer) {
  133 + searchController.isActive=false
  134 + }
  135 + func willPresentSearchController(_ searchController: UISearchController) {
  136 + grayView.isHidden=false
49 137 }
  138 + func willDismissSearchController(_ searchController: UISearchController) {
  139 + searchTableHeight.constant=44
  140 + grayView.isHidden=true
  141 + }
  142 + //谓词搜索过滤
  143 + func updateSearchResults(for searchController: UISearchController) {
  144 + let searchString=searchController.searchBar.text
  145 + let predicate=NSPredicate(format: "SELF CONTAINS[c] %@", searchString!)
  146 + searchAry=(dataSetAry as NSArray).filtered(using: predicate) as! [String]
  147 + if CGFloat((searchAry.count+1)*44)>(getScreenHeight()-64){
  148 + searchTableHeight.constant=getScreenHeight()-64
  149 + }else{
  150 + searchTableHeight.constant=CGFloat((searchAry.count+1)*44)
  151 + }
  152 + searchTableView.reloadData()
  153 + }
  154 +
50 155 }
51 156  
  157 +
52 158 extension ResourceViewController:UICollectionViewDelegate,UICollectionViewDelegateFlowLayout,UICollectionViewDataSource{
53 159  
54 160 func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
... ... @@ -66,7 +172,18 @@ extension ResourceViewController:UICollectionViewDelegate,UICollectionViewDelega
66 172 }
67 173  
68 174 class ResourceViewControllerTableViewCell:UITableViewCell{
69   -
  175 + @IBOutlet var iconImageView: UIImageView!
  176 + @IBOutlet var titleLabel: UILabel!
  177 + @IBOutlet var updateTeacherLabel: UILabel!
  178 + @IBOutlet var timeLabel: UILabel!
  179 + @IBOutlet var downLoadCountLabel: UILabel!
  180 + func setUpWith(item: MicroCourseModel){
  181 + iconImageView.sd_setImage(with: URL(string: item.f_Img), placeholderImage: UIImage(named: "icon_course_placeholder"))
  182 + titleLabel.text=item.f_Title
  183 + updateTeacherLabel.text="上传者:\(item.f_CreatorName) 老师"
  184 + timeLabel.text=item.f_CreatorTime
  185 + downLoadCountLabel.text="\(item.f_DownloadSum)"
  186 + }
70 187 }
71 188  
72 189  
... ...
YouerLiveVideo/YouerLiveVideo/util/utiles.swift
... ... @@ -49,7 +49,7 @@ class AlertController {
49 49 }
50 50 class Theme{
51 51 static func topBarColor()->UIColor{
52   - return UIColorFromRGB(0xff6533)//UIColorFromRGB(0xff9b34)f6595f
  52 + return UIColorFromRGB(0x1CA2FF)//UIColorFromRGB(0xff9b34)f6595f
53 53 }
54 54 ///按钮样式
55 55 static func configButton(_ button:UIButton){
... ...