Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This code will change alpha of background color of UILabel as per slider value change.</p> <p>first you need to declare slider in custom Cell. as describe bellowed.</p> <p>Declare slider in SignUpCustomCell.h cell.</p> <pre><code>#import &lt;UIKit/UIKit.h&gt; @interface SignUpCustomCell : UITableViewCell { UISlider* slider; UILabel *lblLeft; } @property(nonatomic,retain) UISlider* slider; @property(nonatomic,retain) UILabel *lblLeft; @end </code></pre> <p>alloc memory in SignUpCustomCell.m file.</p> <pre><code>#import "SignUpCustomCell.h" @synthesize slider,lblLeft; - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { if ((self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])) { slider=[[UISlider alloc]initWithFrame:CGRectMake(150, 5, 100, 25)]; [slider setValue:0.0]; slider.minimumValue=0; slider.maximumValue=1; [self.contentView addSubview:self.slider]; self.lblLeft = [[UILabel alloc]init]; self.lblLeft.font = [UIFont fontWithName:@"Helvetica-Bold" size:12]; self.lblLeft.textColor = [UIColor colorWithRed:135.0/255.0 green:135.0/255.0 blue:135.0/255.0 alpha:1.0]; self.lblLeft.backgroundColor = [UIColor greenColor]; [self.lblLeft setTextAlignment:UITextAlignmentLeft]; [self.contentView addSubview:self.lblLeft]; [self.lblLeft release]; } return self; } </code></pre> <p>After creating custom cell.You will used it where you want. </p> <p>To used custome cell in SignupViewController.m . we need following steps.</p> <pre><code>#import "SignUpCustomCell.h" </code></pre> <p>Then write code in cellForRowAtIndexPath.</p> <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; SignUpCustomCell *cell = (SignUpCustomCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[SignUpCustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; } cell.lblLeft.text=@"test app"; cell.slider.tag=indexPath.row; [cell.slider addTarget:self action:@selector(sliedervalue:) forControlEvents:UIControlEventValueChanged]; return cell; } -(void)sliedervalue:(id)sender { UISlider* sl=(UISlider*)sender; NSLog(@"sl=%d",sl.tag); NSLog(@"sl_value=%f",sl.value); NSIndexPath *indexPath=[NSIndexPath indexPathForRow:sl.tag inSection:0] ; SignUpCustomCell *cell = (SignUpCustomCell*)[tblSignup cellForRowAtIndexPath:indexPath]; cell.lblLeft.alpha= sl.value; } </code></pre> <p>Let me know if you have any query. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload