uitableview - how to rotate image in expandable cell when clicked on cell in ios? -
i'm making uitableview expandable/collapsable cells ios app.in want display when user click on cell image down , when click on again image this,it possible! here code
-(void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath { if (selectedindex == indexpath.row) { selectedindex = -1; [mycontesttableview reloadrowsatindexpaths:[nsarray arraywithobject:indexpath] withrowanimation:uitableviewrowanimationfade]; return; } if (selectedindex != -1) { nsindexpath *prevpath = [nsindexpath indexpathforrow:selectedindex insection:0]; selectedindex = indexpath.row; [mycontesttableview reloadrowsatindexpaths:[nsarray arraywithobject:prevpath] withrowanimation:uitableviewrowanimationfade]; } selectedindex = indexpath.row; [mycontesttableview reloadrowsatindexpaths:[nsarray arraywithobject:indexpath] withrowanimation:uitableviewrowanimationfade]; }
in image name "rotataeimage" please me. here expandable cell default image this
when user click on cell image , again user click on cell default image display here
if you're subclassing uitableviewcell
can use: setselected: animated:
, add configuration there.
- (void)setselected:(bool)selected animated:(bool)animated { [super setselected:selected animated:animated]; yourimageview.transform = cgaffinetransformmakerotation(selected ? m_pi : 0); // configure view selected state }
if not, use inside -cellforrowatindexpath
like:
- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { ... yourtablecell.yourimageview.tranform = cgaffinetransformmakerotation((selectedindex == indexpath.row) ? m_pi : 0); ... return tablecell; }
Comments
Post a Comment