Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 06-16-2011, 02:48 AM   #1 (permalink)
Registered Member
 
Join Date: Feb 2011
Posts: 23
rashdan is on a distinguished road
Default xcode, tableview overlapping rows

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.
rashdan is offline   Reply With Quote
Old 06-16-2011, 09:00 AM   #2 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
Join Date: Aug 2008
Location: Memphis, TN, USA
Age: 24
Posts: 3,983
smithdale87 is on a distinguished road
Send a message via AIM to smithdale87
Default

Do you implement the heightForRowAtIndexPath method? Overlapping rows could be caused by the fact that you are telling the tableview to make the row height too short.
smithdale87 is offline   Reply With Quote
Old 06-17-2011, 02:52 AM   #3 (permalink)
Registered Member
 
Join Date: Feb 2011
Posts: 23
rashdan is on a distinguished road
Default

Quote:
Originally Posted by smithdale87 View Post
Do you implement the heightForRowAtIndexPath method? Overlapping rows could be caused by the fact that you are telling the tableview to make the row height too short.
No, I'm not implementing heightForRowAtIndexPath this is what I'm doing

Code:
-(CGFloat)tableView:(UITableView*)tableView heightForHeaderInSection:(NSInteger)section
{
    if (tableView.tag == 1 && section == 1) {
        return 35;
    }
    else
        return 30.0;
}

-(CGFloat)tableView:(UITableView*)tableView heightForFooterInSection:(NSInteger)section
{
    if (tableView.tag == 1 && section == 1) {
        return 50;
    }
    else
        return 30.0;
}
rashdan is offline   Reply With Quote
Reply

Bookmarks

Tags
overlapping, uitableview

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 319
6 members and 313 guests
chemistry, Dnnake, iOS.Lover, lendo, Leslie80, pbart
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,664
Threads: 94,120
Posts: 402,898
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Leslie80
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 02:24 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0