views:

60

answers:

1

Hi, I would like to make my text label on a cell fade out when I press a button. I tried pointing the label I want to make fade out, but it just work for only last cell.

And I found out that -(void) willTransitionToState:(UITableViewCellStateMask)state is the way to solve this problem, but I don't know how to use. Do I need to make a new class that is subclass of UITableViewCell class?

Any help will be appreciated. Thank you!

A: 

Hi,

Have you tried using UIView's animations? That would be something like this:

// Where you want to make the label fade out
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.3]; // in seconds, up to you
cell.textLabel.alpha = 0.0;
[UIView commitAnimations];
Jukurrpa
Hi, Thank you for answering my question. I tried this code, but I could only make fade out the last cell. cell.textLabel did not work, so I used self.textLabel.alpha instead.What I would like to do is something like cell.contentView.thirdLabel.alpha because there are four UIlabels in the cell, but this does not work...
Kazu
Where did you add this code? You could do this for any cell, by using your UITableView's "visibleCells" method (returns an array of currently displayed cells).About your cell, how did you create it? Is it a subclass of UITableViewCell with labels stored in class variables?Maybe you could add some of your code in your original question
Jukurrpa
I still don't get how to use visibleCells.is it something like [TableView visibleCells]; ? I created cell with four labels by code. created cell, and created frames and UILabels, and added subview to the cell.mainLabel = [[[UILabel alloc] initWithFrame:CGRectMake(5.0, 1.0, 290.0, 23.0)] autorelease];//English name mainLabel.tag = 1; mainLabel.font = [UIFont boldSystemFontOfSize:15.0]; mainLabel.textAlignment = UITextAlignmentLeft; mainLabel.textColor = [UIColor blackColor]; [cell.contentView addSubview:mainLabel];thanks!
Kazu
As I said, edit your first post with your code, it will be much more readable. How do you retrieve a pointer to your label? Using [cell viewWithTag:] ?As for visibleCells yes, it is an instance method which returns a NSArray of cells.
Jukurrpa