I have no idea why the tableview is overlapping the row.
I've two sections is my tableview, here's the code for cellForRowAtIndexpath
Code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *CellIdentifier = [NSString stringWithFormat: @"Cell%i",indexPath.row];
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
[cell setSelectedBackgroundView:[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"highlightstrip.png"]]];
if (tableView.tag == 1) {
if(indexPath.section == 0){
UILabel *lblName = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 90, 20)];
lblName.textAlignment = UITextAlignmentLeft;
lblName.font = [UIFont boldSystemFontOfSize:14];
lblName.backgroundColor = [UIColor clearColor];
lblName.tag = 31;
[cell.contentView addSubview:lblName];
[lblName release];
}
else {
UILabel *lblDesc = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 250, 20)];
lblDesc.textAlignment = UITextAlignmentLeft;
lblDesc.font = [UIFont systemFontOfSize:13];
[lblDesc setTextColor:[UIColor colorWithRed:102.0/255.0 green:102.0/255.0 blue:102/255.0 alpha:1.0]];
lblDesc.backgroundColor = [UIColor clearColor];
lblDesc.tag = 35;
[cell.contentView addSubview:lblDesc];
[lblDesc release];
}
}
}
if (tableView.tag == 1) {
if (indexPath.section == 0) {
[(UILabel *) [cell viewWithTag:61] setText:[tableElements objectAtIndex:indexPath.row]];
}
else if (indexPath.section == 1){
NSMutableString *strAddr = [[[NSMutableString alloc] initWithString:@""] autorelease];
UserAddress *tempAddr = [[[UserAddress alloc] init] autorelease];
tempAddr = [[[collection loggedInUser]userDeliveryAddress ] objectAtIndex:indexPath.row];
[strAddr appendString:[tempAddr userAddrLine1]];
[strAddr appendString:@" "];
[(UILabel *) [cell viewWithTag:35] setText:strAddr];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
return cell;
}
Please, help, I don't know where's the problem with the above code.