Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import UIKit
- import AVFoundation
- import FirebaseDatabase
- import FirebaseStorage
- class GuidaTuristicaCollectionCell: UICollectionViewCell {
- @IBOutlet weak var imagePlaces: UIImageView!
- // here i download the image
- var place: Place! {
- didSet {
- if let place = place {
- Utility().getImage(withName: place.imageName!, completion: { (image) in
- DispatchQueue.main.async {
- self.imagePlaces.image = image
- self.activityIndicator.stopAnimating()
- self.activityIndicator.hidesWhenStopped = true
- }
- })
- }
- }
- }
- }
- class GuidaTuristicaCell: UITableViewCell {
- @IBOutlet weak var collectionView: UICollectionView!
- }
- class GuidaTuristica: UIViewController, UITableViewDataSource, UITableViewDelegate, UICollectionViewDataSource, UICollectionViewDelegate {
- //MARK: Variables
- var place: Place?
- var places = [Place]()
- override func viewDidLoad() {
- super.viewDidLoad()
- tableView.delegate = self
- tableView.dataSource = self
- }
- // MARK: - Table view data source.
- func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
- return 1
- }
- func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
- let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! GuidaTuristicaCell
- cell.collectionView.dataSource = self
- cell.collectionView.delegate = self
- return cell
- }
- //MARK: Collection View
- func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
- return places.count
- }
- func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
- let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as! GuidaTuristicaCollectionCell
- cell.place = place
- return cell
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement