mirror of
https://github.com/wahyd4/Yep.git
synced 2026-08-16 08:16:55 +10:00
fill dribbbleShots to dribbbleCollectionView
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import Kingfisher
|
||||
|
||||
class SocialWorkDribbbleViewController: UIViewController {
|
||||
|
||||
@@ -21,6 +22,12 @@ class SocialWorkDribbbleViewController: UIViewController {
|
||||
return CGRectGetWidth(self.dribbbleCollectionView.bounds)
|
||||
}()
|
||||
|
||||
var dribbbleShots = Array<DribbbleWork.Shot>() {
|
||||
didSet {
|
||||
updateDribbbleCollectionView()
|
||||
}
|
||||
}
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
@@ -48,12 +55,20 @@ class SocialWorkDribbbleViewController: UIViewController {
|
||||
|
||||
}, completion: { dribbbleWork in
|
||||
println("dribbbleWork: \(dribbbleWork.shots.count)")
|
||||
|
||||
dispatch_async(dispatch_get_main_queue()) {
|
||||
self.dribbbleShots = dribbbleWork.shots
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Actions
|
||||
|
||||
func updateDribbbleCollectionView() {
|
||||
dribbbleCollectionView.reloadData()
|
||||
}
|
||||
|
||||
func gotoUserDribbbleHome() {
|
||||
// TODO: gotoUserDribbbleHome
|
||||
}
|
||||
@@ -67,14 +82,16 @@ extension SocialWorkDribbbleViewController: UICollectionViewDataSource, UICollec
|
||||
}
|
||||
|
||||
func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
|
||||
return 30
|
||||
return dribbbleShots.count
|
||||
}
|
||||
|
||||
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
|
||||
|
||||
let cell = collectionView.dequeueReusableCellWithReuseIdentifier(dribbbleShotCellIdentifier, forIndexPath: indexPath) as! DribbbleShotCell
|
||||
|
||||
cell.imageView.image = UIImage(named: "Cover3")
|
||||
let shot = dribbbleShots[indexPath.item]
|
||||
|
||||
cell.imageView.kf_setImageWithURL(NSURL(string: shot.images.normal)!)
|
||||
|
||||
return cell
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user