iOS How to expand only one cell -
i have try write first app , have encountered problem seems not able find solution.
i trying expand cell height that's being tapped. followed link when clicked on 1 cell, rest of cells expanded too. know why happening?
here simple implementation of problem.
#import "viewcontroller.h" @interface viewcontroller ()<uitableviewdatasource,uitableviewdelegate> { nsindexpath *selectedindexpath; } @end @implementation viewcontroller - (void)viewdidload { [super viewdidload]; selectedindexpath = [nsindexpath new]; } - (nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section { return 10; } - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:@"mycell"]; return cell; } - (cgfloat)tableview:(uitableview *)tableview heightforrowatindexpath:(nsindexpath *)indexpath { if ( indexpath == selectedindexpath) { return 200; } else { return 90; } } - (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath { selectedindexpath = indexpath; [tableview reloaddata]; } @end
Comments
Post a Comment