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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:36:33+00:00 2026-05-25T13:36:33+00:00

The task I’m currently trying to do with UITableViewController is to have one-column-cell-row in

  • 0

The task I’m currently trying to do with UITableViewController is to have one-column-cell-row in portrait mode, and two-column-cell-row in landscape mode. It’s just for the viewing convenience (using available width space for viewing more rows-cells), so both column cells are of the same format. However, I’m not sure how to implement that.

So, the thought is to have my cell customization stuff in “cellForRowAtIndexPath” method and to check for the current screen mode. The question is do I have to set some flag at “shouldAutorotateToInterfaceOrientation” or there is some setting for that?

Second, would it be enough to call just table reload in “shouldAutorotateToInterfaceOrientation” in order to redraw cells of my table?

Also, I’m thinking about making different nib and designing my cell in IB. I guess it’s another question, just wondering how does that would affect the solution.

  • 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-25T13:36:34+00:00Added an answer on May 25, 2026 at 1:36 pm

    You have to check the current orientation in cellForRowAtIndexPath and configure your cell properly. You can create 2 different cells with IB.

    Also, you have to call [myTableView reloadData] in one of the callbacks for rotation events (shouldAutorotateToInterfaceOrientation or didRotateFromInterfaceOrientation). cellForRowAtIndexPath will be called each time you call [myTableView reloadData] (for all cells).
    Be sure you use different identifiers for reusing cells.

    EDIT: This is how I would code this:

    Add 2 IBOutlets to your .h file:

    IBOutlet MyCustomCell1 * customCell1;
    IBOutlet MyCustomCell2 * customCell2;
    

    In Interface Builder, set the identifier property of each cell, maybe something like cellIdentifier1 and cellIdentifier2. Be sure that the file’s owner in IB is your dataSource (the place where cellForRowAtIndexPath is implemented).

    cellForRowAtIndexPath should look like this:

    -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
        if ([UIDevice currentDevice].orientation == UIDeviceOrientationLandscapeLeft 
        || [UIDevice currentDevice].orientation == UIDeviceOrientationLandscaperight) 
        {
             //Landscape, lets use MyCustomCell2.
             NSString * cellIdentifier2 = @"cellIdentifier2";
    
             MyCustomCell2 * cell  = (MyCustomCell2 *) [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    
             if (cell == nil) {
             //We have to initialize the cell, we're going to use IB
             [[NSBundle mainBundle] loadNibNamed:@"CustomCell2NibName" owner:self options:nil];
             //After this, customCell2 we defined in .h is initialized from IB 
             cell = customCell2;
    
             }
             //setup the cell, set text and everything.
    
             return cell;
        }
    
        else
        {
        //portrait case, the same as before but using CustomCell1
        NSString * cellIdentifier1 = @"cellIdentifier1";
    
             MyCustomCell1 * cell  = (MyCustomCell1 *) [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    
             if (cell == nil) {
             //We have to initialize the cell, we're going to use IB
             [[NSBundle mainBundle] loadNibNamed:@"CustomCell1NibName" owner:self options:nil];
             //After this, customCell1 we defined in .h is initialized from IB 
             cell = customCell1;
    
             }
             //setup the cell, set text and everything.
    
             return cell;
    
    
         }
    

    }

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

Sidebar

Related Questions

the task is quite simple, but i have not figured it out yet. one
Task 1: Read each row from one csv file into one seprate txt file.
Task at hand — I have three versions of some code, developed by different
TASK : I have an existing xml document (UTF-8) which uses xml namespaces and
Task: I have a camera mounted on the end of our assembly line, which
Simple task like make AJAX request , pass one parameter and return result, can
My task for this evening is to show and hide a div (eventually two
Task: Cut or erase a file after first walk-through. i have an install file
Task is: I have task queue stored in db. It grows. I need to
The task that I'm trying to handle is to create a set of wrappers

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.