ios - Need help creating custom collection view properly -


okay, green squares images, size of row example below based on image size determine how look.

i unsure how 3 rows, , that. have tried setting using insetforsectionatindex , insetforsectionatindex doesn't right. have attached code, , expected result below:

code:

    class random : uiviewcontroller, uicollectionviewdelegate, uicollectionviewdatasource{     var random = [1, 1, 1, 1, 1]     override func viewdidload() {      }      func collectionview(collectionview: uicollectionview, cellforitematindexpath indexpath: nsindexpath) -> uicollectionviewcell {         let cell = collectionview.dequeuereusablecellwithreuseidentifier("youtuberesponsivecell", forindexpath: indexpath) as! uicollectionviewcell          return cell     }      func collectionview(collectionview: uicollectionview, didselectitematindexpath indexpath: nsindexpath) {         /*youtube video selected*/     }      func collectionview(collectionview: uicollectionview, numberofitemsinsection section: int) -> int {         return 3     }      func numberofsectionsincollectionview(collectionview: uicollectionview) -> int {         return 2     } }  class xplainnavigationcontroller : uinavigationcontroller{  }  extension random : uicollectionviewdelegateflowlayout{      func collectionview(collectionview: uicollectionview,         layout collectionviewlayout: uicollectionviewlayout,         sizeforitematindexpath indexpath: nsindexpath) -> cgsize {             var cellsizing : cgsize = uiimage(named: "imagehere")!.size                     return cellsizing      }      func collectionview(collectionview: uicollectionview,         layout collectionviewlayout: uicollectionviewlayout,         insetforsectionatindex section: int) -> uiedgeinsets {             return uiedgeinsetszero /*spacing each video.*/     }      func randomint(min: int, max:int) -> int {         return min + int(arc4random_uniform(uint32(max - min + 1)))     }  } 

expected result: http://i.stack.imgur.com/jegje.png


Comments

Popular posts from this blog

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

python - Mongodb How to add addtional information when aggregating? -

java - Incorrect order of records in M-M relationship in hibernate -