Animate buttons in a cell

Discussion in 'iPhone/iPad Programming' started by mrl72, Jan 13, 2011.

  1. macrumors regular

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

    Code:
    	int i=0,i1=0; 
    	
    	while(i<noImages){
    			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++;
    	}
    
    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):

    Code:
    			[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?

    Cheers.
     
  2. macrumors 68030

    PhoneyDeveloper

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

    Joined:
    Apr 20, 2008
    #3
    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