iphone - How to passing different data on UICollection every time user push the button? -
can show me how passing different data on uicollection every time user push button, each button 1 data , have 3 button. need know how passing data using button trigger change data. code far:
@ibaction func opennewfilter(sender: anyobject) { self.collectionview.datasource = self } func numberofsections() -> int { return 2 } //for collectionview, number of filters in section func collectionview(collectionview: uicollectionview, numberofitemsinsection section: int) -> int { if section == 0 { return self.filters.count } else if section == 1 { println("great") return 1 } else { return 0 } } func collectionview(collectionview: uicollectionview, cellforitematindexpath indexpath: nsindexpath) -> uicollectionviewcell { let cell = collectionview.dequeuereusablecellwithreuseidentifier("filter_cell", forindexpath: indexpath) filterthumbnailcell var filterthumbnail = self.filterthumbnails[indexpath.row] cell.filtertitle.text = filterthumbnail.filtername //lazy loading if indexpath.section == 0 { // set standard cell, using data army if filterthumbnail.filteredthumbnail != nil { cell.imageview.image = filterthumbnail.filteredthumbnail } else { cell.imageview.image = filterthumbnail.originalthumbnail //filterthumbnail class instance filterthumbnail.generatethumbnail({ (image) -> void in if let cell = collectionview.cellforitematindexpath(indexpath) as? filterthumbnailcell { cell.imageview.image = image } }) } } else if indexpath.section == 1 { //set "+" cell println("booya") } return cell }
you can initialize filterarray
different content in each action , use in collectionview
.
Comments
Post a Comment