ios - Show the same image in cells of UICollectionView -


i need show same image in cells of uicollectionview following logic:

  • i have 14 different background images
  • i need repeat same image every cell multiple of 14.

eg:

indexpath.row == 1 ,    indexpath.row == 14,    indexpath.row == 28  

and on, put 1 image

indexpath.row == 2 ,    indexpath.row == 15,    indexpath.row == 29  

set image, , on.

how possible fix request ?

i tried code, seems no success :(

- (void)setimageforcell:(uicollectionviewcell *)curcell forindexpath:(nsindexpath *)indexpath { //=>    service image uiimageview *imgservice = (uiimageview *)[curcell viewwithtag:101];  (nsuinteger = 0; < 14; i++) {     if (i == indexpath.row && indexpath.row % 13 == 0)     {         imgservice.image        = [uiimage imagenamed:[nsstring stringwithformat:@"service_%d" , i]];     } } } 

thanks

try this:

if(indexpath.row < 14) {     imgservice.image = [uiimage imagenamed:[nsstring stringwithformat:@"service_%d" , indexpath.row]]; } else {      if (indexpath.row % 14 == 0)      {          (nsuinteger = 0; < 14; i++)          {             imgservice.image = [uiimage imagenamed:[nsstring stringwithformat:@"service_%d" , i]];          }      } } 

or

imgservice.image = [uiimage imagenamed:[nsstring stringwithformat:@"service_%d" , indexpath.row % 14]]; 

Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -