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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T10:09:32+00:00 2026-05-21T10:09:32+00:00

I am using CGRectMake to produce a label and a textField inside of a

  • 0

I am using CGRectMake to produce a label and a textField inside of a UITableViewCell. Here is the code:

   label = [[UILabel alloc] initWithFrame:CGRectMake(20, 10, 0, 20)];
   label.backgroundColor = [UIColor redColor];      

   textField =
     [[UITextField alloc] initWithFrame:CGRectMake(0, 10, 0, 20)];
   textField.backgroundColor = [UIColor blueColor];

  [textField setDelegate:self]; // set the delegate to this object
  [textField addTarget:self action:@selector(textFieldDidEndOnExit)
      forControlEvents:UIControlEventEditingDidEndOnExit];

  [self.contentView addSubview:label]; // add label to the cell
  [self.contentView addSubview:textField]; // add textField to cell

First, my understanding is the the parameters are defined as

  CGRectMake(x, y, width, height) 

What I see in the cell is a label on the left with the textField immediately to its right. There is a small space between the two.

I would expect the X,Y coordinates to be relative to a 0,0 point in the upper left of the cell, with positive values going down and to the right.

I am confused by what I see.

I see that the label is located starting at the left of my cell, but it has an X value greater than the X value of the textField. The textField starts to the right of the label.

I don’t understand why the width value for each is set to 0 (zero).

Also, what makes the textField take a position relative to the label, rather than relative to the cell coordinates.

Here is a simple sketch of the cell and what I see in it (with the background colors set, I can clearly see where the CGRects are being placed):

0,0---------------------------------------------------------------------------------
|                                                                                   |
|   ----------------    -----------------------------------------------------------------
|  |                |  |    
|  |  label         |  |   textField 
|  |                |  |    
|   ----------------    -----------------------------------------------------------------
|                                                                                   |
------------------------------------------------------------------------------------

I also notice that the width of each label varies according to its content length. I understand this, but I don’t understand why the textField moves around, staying the same distance from the label in each case.

[edit] By the way, “self” is a subclass of UITableViewCell, if I didn’t make that clear.

  • 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-21T10:09:33+00:00Added an answer on May 21, 2026 at 10:09 am

    enter image description here

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

Sidebar

Related Questions

I am using 4 UILabels in one view. -(void)setQuestion{ Challenge = [[[UILabel alloc] initWithFrame:CGRectMake(16,
I'm using a UIWebView like that in the viewDidLoad: webView = [[UIWebView alloc] initWithFrame:CGRectMake(0,
I am using CCUIViewWrapper Class to add UIControl in Cocos2d. Here is my code,
I've create a subview using following code: -(void) viewDidLoad { CGRect subviewRect = CGRectMake(0,
i have to create an 2images and 3 labels by using code (cgrectmake)and i
I am using this code: CGRect myRect = CGRectMake(self.frame.size.width, self.frame.size.height); But it gives this
I am opening youtube link in webview using following code. [self playVideo:@www.youtube.com/watch?v=GcpFTAqvLYQ frame:CGRectMake(0, 44,
I ma using CGRectMake in my code but it is not affecting the following
I am using the following code to create a custom switch: UISegmentedControl* switchView=[[UISegmentedControl alloc]
Im using a UIDatePicker on ModeTime, but is very slow?? here the code: #import

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.