Unable to Access UILabel in UITableViewCell

Posted by Nirmal on Stack Overflow See other posts from Stack Overflow or by Nirmal
Published on 2009-10-03T11:34:54Z Indexed on 2010/06/15 21:02 UTC
Read the original article Hit count: 177

I am having trouble in accessing which is in the UITableViewCell, that i have placed in my main .xib file.

That Label is connected to IBOutlet servicesCell.

And the Label inside the table view cell is connected through IBOutlet serviceLabel.

At runtime i am not getting the text which i am assining to that label.

Following is my sample code for that.

static NSString *ServiceIdentifier = @"ServiceIdentifier";

UITableViewCell *cell1 = [tableView dequeueReusableCellWithIdentifier:ServiceIdentifier];

if(cell1 == nil) {
    [[NSBundle mainBundle] loadNibNamed:@"servicesCell" owner:self options:nil];
    cell1 = servicesCell;
}

// label access
serviceLabel = (UILabel *)[cell1 viewWithTag:1];
serviceLabel.numberOfLines = 3;
serviceLabel.lineBreakMode = UILineBreakModeWordWrap;
[serviceLabel setTextAlignment:UITextAlignmentLeft];
[serviceLabel setText:@"Testing String"];

Anyone have any idea then please help..

Thanks in advance..

© Stack Overflow or respective owner

Related posts about iphone

Related posts about iphone-sdk