just as to make it clear all other similar questions are asking for objective C or either not in storyboard hence my question is valid..
So I want to do is create a full screen image slider. Im using collection view to do it. but the outcome is not as expected especially the scrolling and the way the cell is displayed.
here is my code for collection view:
import UIKit
import Firebase
import FirebaseDatabase
import SDWebImage
class DoceFullImageVIew: UIViewController {
@IBOutlet weak var colltionView: UICollectionView!
var images = [ChudoInsta]()
// var imgArr = [ChudoInsta]()
var dbRef: DatabaseReference!
let viewImageSegueIdentifier = "doceImageSegueIdentifier"
override func viewDidLoad() {
super.viewDidLoad()
dbRef = Database.database().reference().child("wedding/doce_pics")
loadDB()
}
func loadDB(){
dbRef.observe(DataEventType.value, with: { (snapshot) in
var newImages = [ChudoInsta]()
for chudoInstaSnapshot in snapshot.children {
let chudoInstaObject = ChudoInsta(snapshot: chudoInstaSnapshot as! DataSnapshot)
newImages.append(chudoInstaObject)
}
self.images = newImages
self.colltionView.reloadData()
})
}
func printvalue() {
print("This is the doce full image firebase \(images)")
// print("This is the doce full image firebase \(images)")
}
}
extension DoceFullImageVIew: UICollectionViewDelegate, UICollectionViewDataSource {
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return images.count
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as? DataCollectionViewCell
let image = images[indexPath.row]
cell?.img.sd_setImage(with: URL(string: image.imageUrl), placeholderImage: UIImage(named: "image1"))
return cell!
}
}
extension DoceFullImageVIew: UICollectionViewDelegateFlowLayout {
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
let size = UIScreen.main.bounds
return CGSize(width: size.width, height: size.height)
}
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets {
return UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
//return UIEdgeInsets(0, 5, 0, 5);
}
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat {
return 0
}
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {
return 0
}
}
Can some one point out what is wrong and why the output comes like this images chopped : https://drive.google.com/file/d/1JzbX-B0dhuInJ_ydwFWyuYTNq6d_lZS_/view?usp=sharing
https://drive.google.com/file/d/1KdPKkcvdAR4lMEY-0nwthsFlS2OxC_Te/view?usp=sharing
and in landscape the images are chopped as well: https://drive.google.com/file/d/1RgqUCtUL_L2Xystg1eDDm7ZMBBhqaZvj/view?usp=sharing
here are some of my story board screenshots: https://drive.google.com/file/d/1NMzvSHfEHWil_HsMtELmU4kd2Awe4nXt/view?usp=sharing https://drive.google.com/file/d/1Q6DiBWWXGCzZ6bVKn9dkprMeluXuuonW/view?usp=sharing https://drive.google.com/file/d/1-CB_XtGSI_rXpqbckytGgNrdaH1upaUy/view?usp=sharing https://drive.google.com/file/d/1r4gAV2p_VS4Ix5ht_HPQVe7Rs8LeKtpX/view?usp=sharing
my flow delegate: https://drive.google.com/file/d/1BjIBwvTVe0Ew_MAKBpeorkowQlDdD3eT/view?usp=sharing
Im trying to achieve a fullscreen image slider with collection view(images are retrieved from firebase)