将标签和按钮添加到UICollectionView xcode 9,swift 4

时间:2018-04-28 11:39:14

标签: ios swift xcode uicollectionview uilabel

我在UICollection视图中创建了一个水平滚动的标签。

  
      
  1. 我需要通过满足某些条件来提供在运行时在该标签上显示的数据。
  2.   
  3. 通过点击该标签,它应该从表格视图中过滤数据并将其显示在同一个表格视图中
  4.   

View Controller

CODE:

let xxx = ["Appointments", "Waitlisted", "Suspended", "Billing", "Cancelled", "Transfer", "Revoked", "Checkedin"]
// This dummy count data should be provided in the runtime by satisfying some condition, just to check I have created a compile time value
    let dummyCount = ["5", "10", "2", "3","6","1", "5", "2"]

public func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        return xxx.count
        return dummyCount.count

    }
public func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "statusDisplayCell", for: indexPath) as! statusDisplayCollectionViewCell
        cell.countOfStatusCell.text = dummyCount[indexPath.row]
        cell.xxxCell.text = xxx[indexPath.row]
        return cell
    }

0 个答案:

没有答案