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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:13:30+00:00 2026-05-22T21:13:30+00:00

I have a GUI class extending UIViewController. In its function viewDidLoad , I would

  • 0

I have a GUI class extending UIViewController.

In its function viewDidLoad, I would like to have a UITextField instance. I would like that instance not aligned as a simple CGRect, setting its offset and width and height, but I want it rather to be resized dynamically, making it fill the whole width of the screen, with an offset of 5px from top, left and right each and a height of 20px. How is that done?

It should maintain the “relatively-absolute” positioning regardless of the device orientation, all orientations being supported.

Maybe there’s something like a LayoutManager, as, for instance, GridBagLayout in Java?

  • 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-22T21:13:30+00:00Added an answer on May 22, 2026 at 9:13 pm

    You want to set the autoresizingMask property of the view.

    UIView *theParentView; // Assume this is the root view that owns the whole screen
    
    CGRect textFieldFrame = CGRectMake(5, // Top-left corner x position
                                       5, // Top-left corner y position
                                       [theParentView bounds].width - 10, // Width
                                       20); // Height
    
    UIView *myView = [[UIView alloc] initWithFrame:textFieldFrame];
    
    // This will make it resize with the parent view, maintaining margins
    [myView setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
    
    [theParentView addSubview:myView];
    
    [myView release];
    

    This can all be done from Interface Builder as well. There’s even a little animation showing how the view will resize in Interface Builder.

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

Sidebar

Related Questions

I have a class like this class GUI : public QWidget, public QThread When
I have a class (simulation) which creates an instance of another class (GUI). Inside
I have a GUI tool that manages state sequences. One component is a class
I have a function in a utility class namespace GUI.code { public class Utility
I have a java class that extends from JPanel. The basic purpose of extending
I have a GUI class and a database class. I do something like: Dim
For example I have a class that builds the GUI, a class that handles
I have a class that draws a GUI, using gtk. Clicking a button will
Starting my first serious GUI app in C#. I have a class that is
Basically I have a method in my Gui class that prints and appends text

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.