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 745085
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T09:03:14+00:00 2026-05-14T09:03:14+00:00

I added the interfaceOrientation to my app. It works fine concerning the views. Some

  • 0

I added the interfaceOrientation to my app. It works fine concerning the views. Some of the table-cells I defined by CGRects to position the text in the cell. In portrait-mode the cell is 300px long, in landscape-mode 420px. I use the following code to change the CGRects depending the orientation:

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

    if (self.interfaceOrientation == UIDeviceOrientationPortrait) {
        NSString *currentLanguage = [[NSString alloc] initWithContentsOfFile:[NSHomeDirectory() stringByAppendingPathComponent:@"/Documents/sprache.txt"]]; 
        static NSString *TableViewTableCellIdentifier = @"TableViewTableCellIdentifier";
        UITableViewCell *cell = (UITableViewCell *) [tableView dequeueReusableCellWithIdentifier:TableViewTableCellIdentifier];

        CGRect cellRect = CGRectMake(0, 0, 300, 175);
        cell.backgroundColor = [UIColor darkGrayColor];
        cell = [[[UITableViewCell alloc] initWithFrame:cellRect reuseIdentifier:TableViewTableCellIdentifier] autorelease];

        CGRect keyLabelRect = CGRectMake(0, 5, 5, 20);
        UILabel *keyLabel = [[UILabel alloc]initWithFrame:keyLabelRect];
        keyLabel.tag = 100; //.........
    } else {
        NSString *currentLanguage = 
            [[NSString alloc] initWithContentsOfFile:[NSHomeDirectory() stringByAppendingPathComponent:@"/Documents/sprache.txt"]];   
        static NSString *TableViewTableCellIdentifier = @"TableViewTableCellIdentifier";

        UITableViewCell *cell = (UITableViewCell *) [tableView dequeueReusableCellWithIdentifier:TableViewTableCellIdentifier];

        CGRect cellRect = CGRectMake(0, 0, 450, 175);
        cell.backgroundColor = [UIColor darkGrayColor];
        cell = [[[UITableViewCell alloc] initWithFrame:cellRect reuseIdentifier:TableViewTableCellIdentifier] autorelease];

        CGRect keyLabelRect = CGRectMake(0, 5, 5, 20);
        UILabel *keyLabel = [[UILabel alloc] //.....
    }
}

My problem is, when the table is visible and the orientation is changed, I need to scroll to see the new “layout”. How can I manage to “reload” the view after changing the orientation?

  • 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-05-14T09:03:15+00:00Added an answer on May 14, 2026 at 9:03 am

    First of all, this will leak like mad. You create cells and dequeue them but you never release them. You just create an entirely new cell every time a cell is requested. There is no reason to recreate a cell if you dequeue and vice versa. More importantly, your creating as many cells as you have rows in your logical table. That will eat all your memory very quickly.

    When you dequeue a cell, you need to check if it’s frame is the right size and reuse it if it is. If it is not, then you need to release the cell and create another one.

    Second, a table will not ask for new cells until you scroll the existing cells off the screen. This is why your cells do not change until you scroll. It’s the expected behavior of a tableview.

    My standing recommendation for any moderately complex view is to use different view-controller/view pairs for each orientation. It seems like more work but usually I find it it actually takes less and it’s easier to manage. In this case, having two separate tables will probably save you a lot of grief.

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

Sidebar

Related Questions

I added some simple WatiN tests to our app today to check that a
I added some custom fields (public booleans) to the global class in global.asax.cs which
I added a text file to a testapp's solution and I want to read
Whenever my app is rotated, only the viewController of which I've added his view
added a foreign key relationship to a table in order to do so I
in my application I have a background functions which caches data - works fine.
I added CCLabel in my update method to display my game score. It works
I am Started my iPad app using View-Based application. in first two views i
I added a wav file to my Windows Mobile app and I want to
I added few custom pages to my Installer. These pages gather some data from

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.