Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8791599
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:51:54+00:00 2026-06-13T22:51:54+00:00

Hey guys i’ve been stuck on this problem for 2 days in a row,

  • 0

Hey guys i’ve been stuck on this problem for 2 days in a row, so i’m asking if there is anybody out there that can give me a hand.

I have a tableview that is made up of 4 sections.

section 1 ->made up of just 1 row where its cell contains a subview which is a uiimageview

section 2 ->made up of 2 normal rows(just 2 plain simple cells with text in them)

section 3 -> made up of 1 normal row

section 4 -> made up of 1 row, where its cell contains a subview which is a uitextview that can contain dynamic text, so the uitextview’s height and consequently the cells height varies depending on how much text is in the uitextview.

Here’s the code to create this structure:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{


//create a nsstring object that we can use as the reuse identifier
static NSString *CellIdentifier = @"Cell";

//check to see if we can reuse a cell from a row that has just rolled off the screen
UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

//if there re no cells that can be reused, create a new cell
if(cell==nil){
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];


    switch (indexPath.section) {
        case 0:
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            [cell.contentView addSubview:_viewForImageHeader];

            break;

        case 1:
            cell.selectionStyle = UITableViewCellSelectionStyleGray;
            cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

            cell.textLabel.numberOfLines = 0;
            cell.textLabel.lineBreakMode = 0;
            cell.textLabel.font = [UIFont fontWithName:@"AmericanTypewriter" size:16.0];

            break;

        case 2:
            cell.selectionStyle = UITableViewCellSelectionStyleGray;
            cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
            cell.textLabel.font = [UIFont fontWithName:@"AmericanTypewriter" size:16.0];
            break;

        default:
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            [cell.contentView addSubview:_textViewForArticle];

            break;

    }

}
else{

    NSLog(@"in else");

}


//here i fill in the 2 normal cells with text


return cell;

}

When the uitableview loads(in portrait mode) everything is perfect(image is in section 1, section 2 and 3 contain their correct text and in section 4 i have my dynamic text). But when i start to rotate the app, all the cells get mixed up. For example i find the contents of section3 in section 4 and vice versa.

I think this has to with the fact that i am not maybe reusing the cells correctly. Should i use tags, and if so, how can i implement the use of tags in the specific case?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T22:51:55+00:00Added an answer on June 13, 2026 at 10:51 pm

    Put switch case outside if condition – after the if and else

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey guys was hoping you can help me out. been at this for like
hey guys having this really simple problem but cant seem to figure out have
Hey guys can you help me figure this one out!? I'm still researching for
hey guys hope you can help me out, I am having a weird problem.
Hey Guys I've been struggling with this for the last hour and pouring over
Hey guys (be forewarned that this question makes me feel n00b so I probably
hey guys i know this may sound stupid, but i am stuck with this
Hey guys this is my html code: <div class=nakupy> <li class=icn_kategorie><a href=#>Nákupy</a> <div class=sub_menu>
Hey guys (and gals) I'm having a problem using Assembly GetExportedTypes() in .NET 4.0.
Hey guys was hoping you could help me out. basically i'm working on a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.