Home Scroll UICollectionView to bottom
Reply: 0

Scroll UICollectionView to bottom

user9073 Published in September 19, 2018, 6:44 pm

I would like to scroll the UICollectionView to the bottom so the last item is in the view. I have tried to use scrollToItemAtIndexPath but it does not seem to be working. I want this to happen after I have completed a query with Parse.com


    var query = PFQuery(className:"Chat")
    //        query.whereKey("user", equalTo:currentUser)
    query.whereKey("rideId", equalTo:currentObjectId)

    query.findObjectsInBackgroundWithBlock {
        (objects: [AnyObject]!, error: NSError!) -> Void in
        if error == nil {
            // The find succeeded.
            NSLog("Successfully retrieved \(objects.count) scores.")
            // Do something with the found objects
            for object in objects {
                NSLog("%@", object.objectId)

                var testId = object.objectId



                var message = object.objectForKey("message") as String
                self.messageString = message

                var nameId = object.objectForKey("user") as PFUser
                var username = nameId.username as String
                self.nameString = username

                println("username: \(username)")


        } else {
            // Log details of the failure
            NSLog("Error: %@ %@", error, error.userInfo!)
                    NSLog("Ordered: %@", self.orderedIdArray)    
share|improve this question
  • You say that scrollToItemAtIndexPath "does not seem to be working". What does it do? – Rob Dec 3 '14 at 17:14
  • I have put it under the line self.collectionView?.reloadData() but it then does not run anything after that line. – Tom Coomer Dec 3 '14 at 17:16
  • This is what I am using. Is this correct?let index = NSIndexPath(forItem:self.messageArray.count, inSection:0) self.collectionView?.scrollToItemAtIndexPath(index, atScrollPosition: UICollectionViewScrollPosition.Bottom, animated: true) – Tom Coomer Dec 3 '14 at 17:21
  • I meant is that the code I should put where the ...is? – Tom Coomer Dec 3 '14 at 17:27

9 Answers 9

active oldest votes
up vote 16 down vote accepted
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.42099 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO