iphone - iOS swift custom UICollectionView with Custom Cell does not call didSelectItem -
i got issues following code: created custom cell custom uicollectionview class. used xib files instead of storyboard. never calls didselectitematindexpath method why? desperate :'(.
import uikit class customcollectionview: uicollectionview, uicollectionviewdatasource, uicollectionviewdelegateflowlayout { var refreshcontrol : uirefreshcontrol = uirefreshcontrol() required init(coder adecoder: nscoder) { super.init(coder: adecoder) self.delegate = self self.datasource = self var flowlayout:uicollectionviewflowlayout = uicollectionviewflowlayout() flowlayout.scrolldirection = uicollectionviewscrolldirection.vertical self.collectionviewlayout = flowlayout self.refreshcontrol.addtarget(self, action: "refreshdata:", forcontrolevents: uicontrolevents.valuechanged) self.addsubview(refreshcontrol) self.userinteractionenabled = true self.registerclass(customcollectionviewcell.self, forcellwithreuseidentifier: "outfit") self.registernib(uinib(nibname: layouthelper.getcellxibname("customcollectionviewcell"), bundle: nil), forcellwithreuseidentifier: "outfit") self.backgroundcolor = uicolor.whitecolor() } // // mark: uicollectionviewdatasource - methods // func collectionview(collectionview: uicollectionview, numberofitemsinsection section: int) -> int { return 3 } func collectionview(collectionview: uicollectionview, cellforitematindexpath indexpath: nsindexpath) -> uicollectionviewcell { var cell : customcollectionviewcell = collectionview.dequeuereusablecellwithreuseidentifier("outfit", forindexpath: indexpath) as! customcollectionviewcell cell.label.text = "outfit #" + string(indexpath.row) let url = nsurl(string: "http://placehold.it/177x370") cell.imageview.sd_setimagewithurl(url, completed: nil) return cell } func collectionview(collectionview: uicollectionview, didselectitematindexpath indexpath: nsindexpath) { println("at index path %i", indexpath.row) }
Comments
Post a Comment