Animate buttons in a cell

Discussion in 'iOS Programming' started by mrl72, Jan 13, 2011.

  1. mrl72 macrumors regular

    Apr 20, 2008
    I have tableview with it's cells containing buttons, and on each button I load in image within the cellForRowAtIndexPath method. So something like:

    	int i=0,i1=0; 
    			UIImage *imageNew = [[UIImage alloc] init] ;
    			imageNew=[imageNew maskImage:[UIImage  imageWithContentsOfFile: item.image]];	
    			UIImage *buttonImageNormal=imageNew;
    			[button setBackgroundImage:buttonImageNormal	forState:UIControlStateNormal  ];
    			[hlcell.contentView addSubview:button];
    I have a page full of image thumbnails that are loaded using the method above but they just abruptly appear on the screen. So I would like to display one thumbnail at a time and maybe have them fade up one by one, something like this (at the end of the above):

    			[button setAlpha:0.0f];
    			[UIView beginAnimations:nil context:NULL];
    			[UIView setAnimationDuration:0.75];
    			[button setAlpha:1.0f];
    			[UIView commitAnimations];
    This does in fact work. It fades up the image as it's supposed to. The problem is it fades ALL the images up the same time, which leads me to believe there is no way to do this. Any thoughts?

  2. PhoneyDeveloper macrumors 68040


    Sep 2, 2008
    You can use a timer or better use the animation completion routine to start a new animation.
  3. mrl72 thread starter macrumors regular

    Apr 20, 2008
    Thanks. Looks like that routine still gets called after the table, cells and buttons have been drawn. Since I'm creating the buttons programatically, I really can't see how to start another animation on the buttons that have already been loaded into the tableview.

Share This Page