Wednesday 15 February 2012

ios - Application crash while adding images to UICollectionViewCell -



ios - Application crash while adding images to UICollectionViewCell -

i need add together image , text on uicollectionviewcell. used code

-(uicollectionviewcell *)collectionview:(uicollectionview *)collectionview cellforitematindexpath:(nsindexpath *)indexpath { static nsstring *cellidentifier = @"cvcell"; cvcell *cell = (cvcell *)[collectionview dequeuereusablecellwithreuseidentifier:cellidentifier forindexpath:indexpath]; nsstring *celldata = [firstsection objectatindex:indexpath.row]; [cell.titlelabel settext:celldata]; nsstring *imagename = [second objectatindex:indexpath.row]; nslog(@"cv setting image row %ld file in bundle name '%@'", (long)indexpath.row, imagename); cell.myimageview.image = [uiimage imagenamed:imagename]; homecoming cell; }

firstsection array have name , sec array have images. text displayed images not working.

so please tell me whats wrong in code.

i got errors this:

2014-11-07 15:18:56.928 collectionviewexample[4459:151457] cv setting image row 0 file in bundle name '( "real_estate_2.png", "photography_2.png", "auto_2.png", "electronics_2.png", "services_2.png" )' 2014-11-07 15:18:56.929 collectionviewexample[4459:151457] -[__nsarrayi length]: unrecognized selector sent instance 0x7be86240 2014-11-07 15:18:57.044 collectionviewexample[4459:151457] *** terminating app due uncaught exception 'nsinvalidargumentexception', reason: '-[__nsarrayi length]: unrecognized selector sent instance 0x7be86240' *** first throw phone call stack: ( 0 corefoundation 0x02bf5df6 __exceptionpreprocess + 182 1 libobjc.a.dylib 0x01975a97 objc_exception_throw + 44 2 corefoundation 0x02bfda75 -[nsobject(nsobject) doesnotrecognizeselector:] + 277 3 corefoundation 0x02b469c7 ___forwarding___ + 1047 4 corefoundation 0x02b4658e _cf_forwarding_prep_0 + 14 5 uikit 0x008ad0be +[_uiassetmanager createassetnamed:frombundle:] + 66 6

the mutual error did in uicollectionview due not writing

[self.mycollectionview registerclass:[mycollectionviewcell class] forcellwithreuseidentifier:@"mycell"];

have tried providing static image in imageview? if works, presume uiimage array might need typecasting

follow link : http://www.techotopia.com/index.php/an_overview_of_ios_6_collection_view_and_flow_layout

ios objective-c uicollectionview uicollectionviewcell

No comments:

Post a Comment