ios - Changing Frame in Collection View's cellForItemAtIndexPath Method -
ios - Changing Frame in Collection View's cellForItemAtIndexPath Method -
i new ios.
i have used collection view. using prototype cell in it. have not used auto-layout in app.
i need alter frame of buttons , view in cellforitematindexpath
. when first scroll move next cell not reflecting first time. can see blank out buttons or view. have checked frames correctly updating. still can not see thing.
though if 1 time again go previous phone call , come seen properly.
please find below code of cellforitematindexpath
- (uicollectionviewcell *)collectionview:(uicollectionview *)collectionview cellforitematindexpath:(nsindexpath *)indexpath { feed *feed; nsmutableattributedstring * string; feed = [arrtop objectatindex:indexpath.row]; shufflecell *mycell = [collectionview dequeuereusablecellwithreuseidentifier:@"shufflecell" forindexpath:indexpath]; mycell.index = indexpath; mycell.delegate = self; // below frame changes not working mycell.vwback.frame = collect.frame; mycell.imgshare.frame = cgrectmake(mycell.imgshare.frame.origin.x, mycell.imgshare.frame.origin.y, self.view.frame.size.width,self.view.frame.size.width ); mycell.lbltext.center = cgpointmake(mycell.imgshare.frame.size.width / 2, mycell.imgshare.frame.size.height / 2); mycell.lbltext.frame = cgrectmake(20 , mycell.imgshare.frame.origin.y + 20, self.view.frame.size.width - 20,self.view.frame.size.width -20); int totheight = (collect.frame.size.height - self.view.frame.size.width); mycell.vwbtn.frame = cgrectmake(mycell.vwbtn.frame.origin.x, collect.frame.size.height -totheight, mycell.vwbtn.frame.size.width, totheight); [mycell.vwbtn setframe:cgrectmake(mycell.vwbtn.frame.origin.x, collect.frame.size.height -totheight, mycell.vwbtn.frame.size.width, totheight)]; mycell.btnfavoriteback.frame = cgrectmake(mycell.btnfavoriteback.frame.origin.x, 0, mycell.btnfavoriteback.frame.size.width, totheight/3); [mycell.btnfavoriteback setframe:cgrectmake(mycell.btnfavoriteback.frame.origin.x, 0, mycell.btnfavoriteback.frame.size.width, totheight/3)]; mycell.btnshare.frame = cgrectmake(mycell.btnshare.frame.origin.x, (totheight/3), mycell.btnshare.frame.size.width, totheight/3); mycell.btnreport.frame = cgrectmake(mycell.btnreport.frame.origin.x, (totheight/3)*2, mycell.btnreport.frame.size.width, totheight/3); mycell.vwlikebtn.frame = cgrectmake(self.view.frame.size.width - 82, (totheight/3 - 32)/2, 82,32); nslog(@"y :- %f",mycell.vwbtn.frame.size.height); homecoming mycell;
i have attached screen shot of same.
thanks help.
adding line should prepare problem. allow subviews of cell translate frames constraints.
cell.label.translatesautoresizingmaskintoconstraints = yes;
ios iphone ipad uicollectionview uicollectionviewcell
Comments
Post a Comment