ios - UILabel In UICollectionViewCell is setting after scrolling? -


in code,i trying use uiimage & uiabel in uicollectionviewcell.what doing if there no image in uicollectionviewcell want shift uilabel upwards.so used 2 frames of label , checked if(uiimageview.image==nil) showing effect after scrolling? do? here code did-

-(uicollectionviewcell *)collectionview:(uicollectionview *)collectionview          cellforitematindexpath:(nsindexpath *)indexpath {  uicollectionviewcell *mycell=(uicollectionviewcell*)[self.view viewwithtag:1]; mycell = [collectionview                           dequeuereusablecellwithreuseidentifier:@"cell"                           forindexpath:indexpath];  uilabel *label=(uilabel*)[mycell viewwithtag:12];  uiimageview *collectionviewimage=(uiimageview*)[mycell viewwithtag:11];    nsstring *collectionviewimagename=[imagescollectionviewarray objectatindex:indexpath.row]; collectionviewimage.image=[uiimage imagenamed:collectionviewimagename];   if (collectionviewimage.image==nil) {  [collectionviewimage setbackgroundcolor:[uicolor clearcolor]]; [label setframe:cgrectmake(35, 73, 309, 54)];  label.text=[lablecolectionviewarray objectatindex:indexpath.row]; return mycell; }else {  [label setframe:cgrectmake(20, 294, 352, 49)]; label.text=[lablecolectionviewarray objectatindex:indexpath.row]; return mycell;   }  } 

try remove cell contentview subviews every collectionview

-(uicollectionviewcell *)collectionview:(uicollectionview *)collectionview cellforitematindexpath:(nsindexpath *)indexpath

method call.

use

for([uiview  *view in cell.contentview.subviews]){     [view removefromsuperview];     view=nil; } 

and replace line of code uicollectionviewcell mycell=(uicollectionviewcell)[self.view viewwithtag:1];

with

uicollectionviewcell *mycell=nil;


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -