Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ViewController: UIViewController, UICollectionViewDelegateFlowLayout, UICollectionViewDataSource {
- let cellId: String = "cellId"
- struct cameraInfo {
- var name: String
- var url: String
- }
- var cameraList: [cameraInfo] = []
- override func viewDidLoad() {
- super.viewDidLoad()
- setupCollectionView()
- let canSeeChannel = ["01", "02", "03", "04", "07", "11", "15", "16", "17", "18", "19", "20"]
- for i in 0...11 {
- cameraList.append(cameraInfo(name: "A\(i+1)", url: "http://61.216.177.73/sta/ch18650\(canSeeChannel[i]).m3u8"))
- }
- }
- var num: Int = 1
- func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
- let cell: CameraCollectionViewCell = collectionView.dequeueReusableCell(withReuseIdentifier: cellId, for: indexPath) as! CameraCollectionViewCell
- cell.camera = nil
- print("\n第\(num)次呼叫")
- num = num + 1
- print("indexPath.item:\(indexPath.item)")
- print(cell.camera)
- cell.camera = Camera(name: cameraList[indexPath.item].name, isConnected: true, isLive: true, url: cameraList[indexPath.item].url)
- print("After setting")
- print(cell.camera.name)
- cell.setupPlayer()
- cell.backgroundColor = .black
- return cell
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment