Krisiacik / ImageViewer

An image viewer à la Twitter
MIT License
2.53k stars 385 forks source link

How to use in UItableview cell - DisplaceableView #137

Open siddharthadeb opened 7 years ago

siddharthadeb commented 7 years ago

As I have two custom cell like chat app. when i added with DisplaceableView array . When I scroll its adding more and more same images in gallery . please help me out, Its very urgent.

Krisiacik commented 7 years ago

Where is the chat UI getting the images? What is the data source for that? Use the same data source for ImageViewer.

DS ---> ChatUI ---> ImageViewer

From what I understand you are somehow passing the data (images) from the chatUI..which is incorrect. IF you want mroe help pls be much more specific incl. code samples.

siddharthadeb commented 7 years ago

I am adding in cell row index method as imageview - please check senderCell?.senderFile?.image = image self.imageViews.append((senderCell?.senderFile)!) let tap = UITapGestureRecognizer(target: self, action: #selector(self.handleTap(_:))) tap.delegate = self senderCell?.senderFile.addGestureRecognizer(tap)

and adding the add items into cell will display

//MARK: willDisplay func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) { for (index, imageView) in self.imageViews.enumerated() { print("image>>>>>",imageView) print("index>>>>>",index)

             guard let imageView = imageView else { continue }
                    var galleryItem: GalleryItem!

                    switch index {

                    default:
                        let myFetchImageBlock: FetchImageBlock = { $0(imageView.image!) }

                        let itemViewControllerBlock: ItemViewControllerBlock = { index, itemCount, fetchImageBlock, configuration, isInitialController in

                            return AnimatedViewController(index: index, itemCount: itemCount, fetchImageBlock: myFetchImageBlock, configuration: configuration, isInitialController: isInitialController)
                        }

                        galleryItem = GalleryItem.custom(fetchImageBlock: myFetchImageBlock, itemViewControllerBlock: itemViewControllerBlock)
                    }

                    self.items.append(DataItem(imageView: imageView, galleryItem: galleryItem))
    }
            print("itemss--->>> ",self.items);

}

please check let me know what to do ?

thechaudharysab commented 6 years ago

How can I get the delete button work?