Advertisement
Guest User

guide

a guest
Feb 21st, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.18 KB | None | 0 0
  1. import UIKit
  2. import AVFoundation
  3. import FirebaseDatabase
  4. import FirebaseStorage
  5.  
  6. class GuidaTuristicaCollectionCell: UICollectionViewCell {
  7.  
  8. @IBOutlet weak var imagePlaces: UIImageView!
  9.  
  10. // here i download the image
  11. var place: Place! {
  12. didSet {
  13. if let place = place {
  14. Utility().getImage(withName: place.imageName!, completion: { (image) in
  15. DispatchQueue.main.async {
  16. self.imagePlaces.image = image
  17. self.activityIndicator.stopAnimating()
  18. self.activityIndicator.hidesWhenStopped = true
  19. }
  20. })
  21. }
  22. }
  23. }
  24.  
  25. }
  26.  
  27. class GuidaTuristicaCell: UITableViewCell {
  28.  
  29. @IBOutlet weak var collectionView: UICollectionView!
  30. }
  31.  
  32. class GuidaTuristica: UIViewController, UITableViewDataSource, UITableViewDelegate, UICollectionViewDataSource, UICollectionViewDelegate {
  33.  
  34. //MARK: Variables
  35.  
  36. var place: Place?
  37. var places = [Place]()
  38.  
  39. override func viewDidLoad() {
  40. super.viewDidLoad()
  41. tableView.delegate = self
  42. tableView.dataSource = self
  43. }
  44.  
  45. // MARK: - Table view data source.
  46.  
  47. func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  48. return 1
  49. }
  50.  
  51. func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  52. let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! GuidaTuristicaCell
  53. cell.collectionView.dataSource = self
  54. cell.collectionView.delegate = self
  55. return cell
  56. }
  57.  
  58. //MARK: Collection View
  59.  
  60. func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
  61. return places.count
  62. }
  63.  
  64. func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
  65. let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as! GuidaTuristicaCollectionCell
  66. cell.place = place
  67. return cell
  68. }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement