i ran problem @ app today. have table inside view controller. problem happens when tap compare
button. when tap compare button, small animation occurs, every cell resized allow selected
or not selected
image appear.
here video problem: https://www.youtube.com/watch?v=6skibp1xf0e
the problem that, while cels should have default not selected
button, cells don't image displayed.
here chuck of code.
//animate function -(void)animate{ [[tableview visiblecells] enumerateobjectsusingblock:^(customcell *cell, nsuinteger idx, bool *stop) { [cell.myimageview setframe:cgrectmake(cell.frame.size.width * 0.15 + cell.myimageview.frame.origin.x, cell.myimageview.frame.origin.y + cell.frame.size.height * 0.1, cell.myimageview.frame.size.width * 1.25, cell.myimageview.frame.size.height * 1.25)]; completion:^(bool finished) { // code execute when animation finishes [uiimageview animatewithduration:1 animations:^{ //select button animation cell.compareproduct.image = [uiimage imagenamed:@"deselectedproduct.png"]; cell.compareproduct.hidden = false; [cell.compareproduct setalpha:0]; [uiimageview beginanimations:null context:nil]; [uiimageview setanimationduration:1.0]; [cell.compareproduct setalpha:1]; [uiimageview commitanimations]; }];} }
this chunk of code executes everytime flawlessly. every cell in see display selected
\ not selected
button. problem happens when scroll.
-(void)tableview:(uitableview *)thetableview willdisplaycell:(uitableviewcell *)cell forrowatindexpath:(nsindexpath *)indexpath{ if (compareactive) //if compare button pressed { [[tableview visiblecells] enumerateobjectsusingblock:^(customcell *cell, nsuinteger idx, bool *stop) { cgrect somerect = cgrectmake(cell.frame.size.width * 0.15 + cell.myimageview.frame.origin.x, cell.myimageview.frame.origin.y + cell.frame.size.height * 0.1, cell.myimageview.frame.size.width * 1.25, cell.myimageview.frame.size.height * 1.25); [cell.myimageview setframe:somerect]; // forced place moving animation user won't notice how image jumps old frame new frame [cell setframe:cgrectmake(cell.frame.size.width, cell.frame.origin.y, cell.frame.size.width, cell.frame.size.height)]; [uiview animatewithduration:1 animations:^{ [cell setframe:cgrectmake(0, cell.frame.origin.y, cell.frame.size.width, cell.frame.size.height)]; }];} }
why cells don't have selected
not selected
displayed , why frame jumps? also, don't forget using customcell.
if have better solution or other functions use please point me them. feature want this: press compare
button, table cells change frames @ 1 time.
thanks in advance.
i think [tableview visiblecells]
, willdisplaycell:
functions aren't match.
it's possible cell firing willdisplaycell:
not returned after when call [tableview visiblecells]
.
i guess should use bool variable in viewcontroller , @ while reloading table view via cellforviewatindexpath:
. , call reloaddata
when user clics on compare button.
Comments
Post a Comment