Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assigning an array's count to collection view. #19

Closed
Dershowitz011 opened this issue Jun 9, 2016 · 3 comments
Closed

Assigning an array's count to collection view. #19

Dershowitz011 opened this issue Jun 9, 2016 · 3 comments
Labels

Comments

@Dershowitz011
Copy link
Contributor

Dershowitz011 commented Jun 9, 2016

I'm declaring a global var items:[UIImage] = [] and I've a

func loadimages(url: String!) -> [UIImage]{

        let unsafe = url

        var data1 = [UIImage]()



        let bingo = NSURL(string: unsafe!)
        Alamofire.request(.GET, bingo!)
        .validate()
            .responseJSON{ response in
                switch response.result{
                case .Success:

                    let json33 = JSON(data: response.data!)

                    let allImageStrings = json33["response"]["docs"].flatMap { $0.1["imageData"].first?.1}


                    for Bro in allImageStrings{

                        let url = NSURL(string: Bro.string!)
                        let data = NSData(contentsOfURL: url!)!
                        let image = UIImage(data: data)


                        data1.append(image!)

                    }

                  self.items = data1



                    //print(self.items.count)

                case .Failure(let error):
                    print(error)
                }


    }


    return data1

    }

But when I run this,

override func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {

    print(self.items.count)
    return items.count

    }

Returns 0. How do I make it return the items.count properly? :(

@0ber
Copy link
Contributor

0ber commented Jun 10, 2016

When your data loaded call collectionView.reloadData()

@Dershowitz011
Copy link
Contributor Author

How do I increase the gap between two cells? Because when I swipe up it goes up and automatically comes down before I swipe down! and every time I do that, the two cells start to merge but they won't! When I swipe right or left, the cells are clearly seen again! :(

@Juriv
Copy link
Contributor

Juriv commented May 2, 2017

hey @Dershowitz011
If the issue is still actual, could you please take a video because we cannot reproduce it

@0ber 0ber added the question label Jan 25, 2018
@Juriv Juriv closed this as completed May 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants