i am creating a UITableview cell in the following way
const NSInteger TOP_LABEL_TAG = 1001;
UILabel *topLabel;
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell =[[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier]
autorelease];
UIImage *indicatorImage = [UIImage imageNamed:@"indicator.png"];
cell.accessoryView =[[[UIImageView alloc] initWithImage:indicatorImage]
autorelease];
const CGFloat LABEL_HEIGHT = 25;
UIImage *image = [UIImage imageNamed:@"64x64.png"];
topLabel =[[[UILabel alloc] initWithFrame:CGRectMake(
image.size.width + 2.0 * cell.indentationWidth,
0.8 * (tableView.rowHeight - 1.7 * LABEL_HEIGHT),
tableView.bounds.size.width -
image.size.width - 4.0 * cell.indentationWidth
- indicatorImage.size.width,
LABEL_HEIGHT)] autorelease];
[cell.contentView addSubview:topLabel];
topLabel.tag = TOP_LABEL_TAG;
topLabel.textColor = [UIColor colorWithRed:0.25 green:0.0 blue:0.0 alpha:1.0];
topLabel.highlightedTextColor = [UIColor colorWithRed:1.0 green:1.0 blue:0.9 alpha:1.0];
topLabel.font = [UIFont systemFontOfSize:20];
topLabel.textAlignment== UITextAlignmentCenter;
}
else
{
topLabel = (UILabel *)[cell viewWithTag:TOP_LABEL_TAG];
}
topLabel.text = [NSString stringWithFormat:[aboutArray objectAtIndex:[indexPath row]]];
topLabel.textAlignment=UITextAlignmentCenter;
first time when the table loads the tableView works fine.But when i navigate back to this page from another page the text in the first cell of table moves on the right and only half of it visisble..What could be the possible reason for it??