Создайте данные модели из магазина и покажите их по идентификатору с другим UICollectionView - PullRequest
0 голосов
/ 18 ноября 2018

У меня есть три разные коллекции в Firestore.

Я добавляю эти данные в эти модели после извлечения их из Firestore с этими кодами .

Мой пользовательский интерфейс является кратным UICollectionView внутри кратного UITableView. Я хочу создать collectionView с количеством пакетов и кормить их JsonStickerPack моделями.

Это мой код, но он не сработал, потому что я не мог правильно скормить эту модель JsonStickerImageEmoji. Я должен отделить их от чего-то:)

        let sp = JsonStickerImageEmoji(imageFile: Stickerdata!, emojis: (packageModel?.description)!)
    let sP1 = JsonStickerPack(stickers: [sp], trayImageFile: trayData!,
                              identifier: docPack.documentID ,
                              name: (packageModel?.name)!,
                              licenseAgreementWebsite: (appX?.licenseAgreementWebsite)!,
                              publisher: (appX?.publisher)!,
                              privacyPolicyWebsite: (appX?.privacyPolicyWebsite)!,
                              publisherWebsite: (appX?.publisherWebsite)!)
    let sP2 = JsonSticker(stickerPacks: [sP1], iosAppStoreLink: (appX?.iosAppStoreLink)!,
                          androidPlayStoreLink: (appX?.androidPlayStoreLink)!)

Коды просмотров коллекции:

    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
    let cell = collectionView.dequeueReusableCell(withReuseIdentifier: cellReuseId, for: indexPath) as? CustomCollectionViewCell

    print("\(cell?.cellImageView.image)")
    cell?.cellImageView.image = UIImage(data : trayImages[indexPath.row])

    return cell!
}

Мои коды контроллеров просмотра:

    func numberOfSections(in tableView: UITableView) -> Int {
   return  categories.count
}

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return 1
}

func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
    return 160
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    var cell = tableView.dequeueReusableCell(withIdentifier: "CustomTableViewCell") as? CustomTableViewCell
    if cell == nil {
        cell = CustomTableViewCell.customCell
    }
    let aCategory = self.categories[indexPath.section]
    cell?.updateCellWith(category: aCategory)

    cell?.trayImages = trayImages
    cell?.stickerImage = stickerImage
    cell?.stickerInfoArray   = stickerInfoArray
    cell?.stickerPackages    = stickerPackages
    cell?.stickerModel       = stickerModel
    cell?.cellDelegate = self
    return cell!
}

Это результат этих кодов.

Я должен отделить их. Кошка к кошке и т.д ..

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...