Answer the question
In order to leave comments, you need to log in
Show photo/video from array in collectionview, scrollview?
Guys, tell
me 1. There is an array where image and video are mixed. What is the best way to identify which URL is which. Since photos and videos are in discord
2. Requires horizontal scrolling. What is the best way to display this? In collectionview, scrollview or other options?
3. While taking a photo or video through enum and switch, or are there other adequate options?
4. I would be grateful for any hint, because the network has options only for video or only for photos
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "DefaultCell", for: indexPath) as? SlideShowCollectionViewCell else { fatalError("\nSlide Show Error Cell\n") }
var urlType = [CellType]()
let urlArray = urlType[indexPath.row]
switch urlArray {
case .image(var url):
url = images[indexPath.row]
cell.imageView.sd_setImage(with: url)
case .video(let url):
cell.videoView.addSubview(playerView)
addPlayer(for: url)
}
}
Answer the question
In order to leave comments, you need to log in
1. if you need to define an action when you click on a cell, then
- by the index of the clicked cell, you get the model from urlType and here's the type for you
2. collectionview
3. there are a lot of them.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question