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

  • Home
  • SEARCH
  • 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 8708217
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:04:24+00:00 2026-06-13T04:04:24+00:00

So, I have a custom cell class and in the implementation I have this

  • 0

So, I have a custom cell class and in the implementation I have this code:

- (void)layoutSubviews {
    [super layoutSubviews];

    CGRect contentRect = self.contentView.bounds;
    CGFloat boundsX = contentRect.origin.x;
    CGRect frame;

    frame = CGRectMake(boundsX+10,10, 50, 50);
    picture.frame = frame;

    frame = CGRectMake(boundsX+75 ,0, 170, 50);
    nameLabel.frame = frame;

    frame = CGRectMake(boundsX+75 ,43, 225, 23);
    costLabel.frame = frame;

    frame = CGRectMake(boundsX+280, 30, 8, 13);
    arrow.frame = frame;
}

Now let’s see how this layout works at the picture below:

enter image description here

I am satisfied with the result, but I also want to change costLabel position in the cell according to the nameLabel. If there are two lines of text in the nameLabel, I don’t want to change the costLabel position, however if there are just one line of text in the nameLabel, I want to move costLabel upper, so I can rid off the space and make costLabel closer to nameLabel.

I tried this in the cellForRowAtIndexPath:

CGRect frame = cell.costLabel.frame;
frame.origin.y = frame.origin.y-10; // new y coordinate
cell.costLabel.frame = frame;

But it didn’t work.

Any solutions or ideas, how can I change CGRect coordinates (y origin) ?

  • 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-13T04:04:25+00:00Added an answer on June 13, 2026 at 4:04 am

    layoutSubviews is going to be called when it wants to draw your cell. Make your frame changes in layoutSubviews (i.e.

    if (thereIsOnlyOneLineInThisCell) {
      frame = CGRectMake(boundsX+75 ,43 -10, 225, 23);
    } else {
       frame = CGRectMake(boundsX+75 ,43, 225, 23);
    }
    
       costLabel.frame = frame;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have custom UITableViewCell . It contains UITextLabel . When I press this cell
I have made major changes and setup a custom class for the TableView Cell.
I have an UILabel in a custom cell class in an UITableView and I
I have a custom table cell class. TextInput.h @interface TextInput : UITableViewCell <UITextFieldDelegate,UIImagePickerControllerDelegate,UINavigationControllerDelegate> {
I have a custom UITableViewCell that I use like this: AppTableCell *cell = [tableView
I have a UITableView with custom cell. I have created seperate class with xib
I have used custom cell class for my uitableview and used in cellForRowAtIndexPath method.
UITableView custom cell showing weird results? I have my code below. Everything was showing
I have a custom cell with identifyer 'tweetCell' I have imported this into my
i have custom cell with 2 buttons(the function of these buttons is just to

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.