ios - Setting an image as a collection Cell -


i'm trying put image collection view cell, pretty much. no fancy stuff, image itself, and, well, @ least resized cell size.

what doing doesn't compile, though feel pretty confident.

context : collection view list of sports, required image. cell holds image , string (the title of sport), , segue page. don't need specific page dynamic, i'll type sports , put images myself, don't need many , no edited, ever.

the collection view called typecollection , in .h (hence _ in code) myevent.typepictures 'event' object holding array of images 'typepictures'.

this array of pictures in event class :

    _typepictures = [[nsmutablearray alloc]initwithobjects:                                           [uiimage imagenamed:@"climbing.jpg"],                                           [uiimage imagenamed:@"skydiving.jpg"],                                           [uiimage imagenamed:@"running.jpg"],                                            [uiimage imagenamed:@"swimming.jpg"],                                           nil]; 

and cell creation method in controller :

    -(uicollectionviewcell *)collectionview:(uicollectionview *)collectionview cellforitematindexpath:(nsindexpath *)indexpath {     static nsstring *cellidentifier = @"cvcell";     uicollectionviewcell *cell = [_typecollection dequeuereusablecellwithreuseidentifier:cellidentifier forindexpath:indexpath];     uiimage *image = [[uiimage alloc]initwithcontentsoffile:[_myevent.typepictures objectatindex:indexpath.row]];     uiimageview *imageview = [[uiimageview alloc]initwithimage:image];     cell.backgroundview = imageview;       return cell;  } 

it stops compiling @ uiimage *image line , gives error in log :

-[uiimage pathextension]: unrecognized selector sent instance 0xa4b4440 2014-05-30 13:55:55.344 apisport[2580:60b] * terminating app due uncaught exception 'nsinvalidargumentexception', reason: '-[uiimage pathextension]: unrecognized selector sent instance 0xa4b4440'

also, if remove 3 lines above return cell;, compiles fine don't have image shown ( have basic pink background had setup manually)

i hope gave enough explanation ! i'm looking

  • why isn't working
  • what should make work, if possible small explanation

thank lot time :)

to correct image need

uiimage *image = _typepictures[indexpath.row];


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -