Tuesday 15 February 2011

ios - UITableViewCell animate resize when user touchdown or tap Cell -



ios - UITableViewCell animate resize when user touchdown or tap Cell -

i want animate uitableviewcell in next image (the cell gets resized smaller) before detailedviewcontroller show. have tried lastly 2 days , tried other answers found similar questions.

i want cell animate/resize user set finger on uitableviewcell.

the uitableviewcell custom cell. have tried setting new frame cell.contentview in uitableviewcell subclass's setselected:(bool)selected animated:(bool)animated method. uitableviewcell didn't resize expected.

what have observed method called when user lifts finger uitableviewcell. want happen user taps cell. , if cell not selected , user moves other cell, cell should resized normal size.

then did searching on receiving touch events uitableviewcell. , tried add together uilongpressgesturerecognizer , uitapgesturerecognizer , in selector tried alter cell.contentview frame

cell.contentview.frame = cgrectmake(cell.frame.origin.x +20, cell.frame.origin.y, cell.frame.size.width-20, cell.frame.size.height); [cell setneedsdisplay];

but selected cell flashing(cell background) not resizing expected.

any suggestions helpful. in advance

okay after reading through doc , going through wwdc videos's able solve this.

i have learned of import thing.

never utilize setframe: on view autolayoutenabled.

keeping in mind changed custom uitableviewcell xib utilize autoresizing masks. , in uitableviewcontroller used these tableview:didhighlightrowatindexpath: tableview:didunhighlightrowatindexpath: delegates

here code snippet view controller.

-(void)tableview:(uitableview *)tableview didhighlightrowatindexpath:(nsindexpath *)indexpath { nslog(@"i'm highlighted @ %ld",(long)indexpath.section); customtableviewcell *cell = (customtableviewcell *)[self.tableview cellforrowatindexpath:indexpath]; originalcellsize = cell.frame; //using animation frame alter transform smooth. [uiview animatewithduration:0.1f animations:^{ cell.frame = cgrectmake(cell.frame.origin.x +20, cell.frame.origin.y, cell.frame.size.width-40, cell.frame.size.height); }]; } -(void)tableview:(uitableview *)tableview didunhighlightrowatindexpath:(nsindexpath *)indexpath { customtableviewcell *cell = (customtableviewcell *)[self.tableableview cellforrowatindexpath:indexpath]; [uiview animatewithduration:0.1f animations:^{ cell.frame = cgrectmake(0, originalcellsize.origin.y, self.view.bounds.size.width, 180) ; }]; originalcellsize = cgrectmake(0, 0, 0, 0); }

ios objective-c iphone uitableview

No comments:

Post a Comment