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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:42:09+00:00 2026-06-01T06:42:09+00:00

I have a UITableView with a custom row. On my custom row I have

  • 0

I have a UITableView with a custom row. On my custom row I have UILAbel with autosizing by width mask, that is why in portrait it has one width and in landscape another.

In my cellForRowAtIndexPath I should get label width:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:
        (NSIndexPath *)indexPath {
    UILabel *myLabel = 
    (UILabel *)[cell viewWithTag:2];
    float width = myLabel.frame.size.width;
}

And when i run application, everything is fine and width is good. But when I rotate device to landscape, cellForRowAtIndexPath called before UILAbel changed its frame, and I’v got the same width as in portrait. So how to be ? How to get right width when I rotate device ? The one idea that comes on my mind is to reload tableView in didRotateForInterfaceOrientation…Is there any other solutions ? Thanks…

UPDATE:

One more thing, when I start application in Landscape mode, width is still like in Portrait. Why ? How to fix that ?

  • 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-01T06:42:10+00:00Added an answer on June 1, 2026 at 6:42 am

    Replace this code with yours. May this will help:

        static NSString *iden = @"Setting";
                UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:iden];
    
                if (cell == nil)
                {
    
                    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:iden];
                    UILabel *label = [[UILabel alloc] init];
                    float xpos = cell.contentView.frame.origin.x ;
                    float ypos = cell.contentView.frame.origin.y;       
                    float nwidth = cell.contentView.frame.size.width ;
                    float nheight = cell.contentView.frame.size.height;
                    label.frame = CGRectMake(xpos, ypos, nwidth, nheight);
    
                    label.tag = indexPath.row + 7777;
    
                    [cell.contentView addSubview:label];
        [label release]
            }
          UILabel *labeltagged =(UILabel*) [cell.contentView viewWithTag:indexPath.row+7777];
        float xpos = cell.contentView.frame.origin.x ;
                    float ypos = cell.contentView.frame.origin.y;       
                    float nwidth = cell.contentView.frame.size.width ;
                    float nheight = cell.contentView.frame.size.height;
                    labeltagged.frame = CGRectMake(xpos, ypos, nwidth, nheight);
    
    return cell;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a custom UITableView cell that has a UIImageView sized to the width
I have a UITableView with two custom cells and each of them has a
I have a UITableView whose cells contain custom ImageViews that asynchronously load the images
I have a UITableView that displays various nsstrings from a custom object called a
I have a UITableView with custom cells. The cells containing one UITextView each and
I have a custom UITableView cell which has a button and a label. I
I have one UITableView with a custom cell loaded from a nib file, it
I have a UITableView with custom UITableViewCells. The table has two sections, the first
I have built a custom UITableView with two cells. In one cell I have
I have a custom cell which has two UILabel objects. //AppEventCell.h #import <UIKit/UIKit.h> @interface

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.