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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:37:17+00:00 2026-06-13T11:37:17+00:00

i have an array for my UITextField to be created. but the UITextField remain

  • 0

i have an array for my UITextField to be created. but the UITextField remain on the same Frame?Here is my code. It create a new UITextField when you press the button.

-(IBAction)textFieldcreating{


    textfieldform = [[NSMutableArray alloc] init];
    textField1 = [[UITextField alloc] initWithFrame:CGRectMake(10, 10, 100, 40)];
    textField1.borderStyle = UITextBorderStyleRoundedRect;
    textField1.font = [UIFont systemFontOfSize:15];
    textField1.placeholder = @"enter text";
    textField1.autocorrectionType = UITextAutocorrectionTypeNo;
    textField1.keyboardType = UIKeyboardTypeDefault;
    textField1.returnKeyType = UIReturnKeyDone;
    textField1.clearButtonMode = UITextFieldViewModeWhileEditing;
    textField1.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;    
    textField1.delegate = self;

    [textfieldform addObject:textField1];

    int counter;
    counter = 0;
    if(counter < [textfieldform count])
    {


            textField1.frame = CGRectMake(textField1.frame.origin.x+30, textField1.frame.origin.x+40, textField1.frame.size.width+40, textField1.frame.size.height+50);
            [self.view addSubview:textField1];

        counter++;
    }

}
  • 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-13T11:37:18+00:00Added an answer on June 13, 2026 at 11:37 am

    What you are doing is creating a new Array and keeping the xOrigin and yOrigin same for all the UITextViews!

    Do something like this.

    In .h file, declare

    @property (nonatomic, retain) NSMutableArray *textfieldform;
    @property (nonatomic, readwrite) int yOrigin;
    

    in .m file, in viewDidLoad function,

    self.textfieldform = [NSMutableArray arrayWithCapacity:0];
    yOrigin = 0;
    

    now, your function looks like this.

    -(IBAction)textFieldcreating{
    
    
        //textfieldform = [[NSMutableArray alloc] init]; NO NEED OF THIS LINE NOW
        textField1 = [[UITextField alloc] initWithFrame:CGRectMake(10, yOrigin, 100, 40)];
        textField1.borderStyle = UITextBorderStyleRoundedRect;
        textField1.font = [UIFont systemFontOfSize:15];
        textField1.placeholder = @"enter text";
        textField1.autocorrectionType = UITextAutocorrectionTypeNo;
        textField1.keyboardType = UIKeyboardTypeDefault;
        textField1.returnKeyType = UIReturnKeyDone;
        textField1.clearButtonMode = UITextFieldViewModeWhileEditing;
        textField1.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;    
        textField1.delegate = self;
    
        [textfieldform addObject:textField1];
    
        yOrigin = yOrigin + 40 + 10; //old yorigin + btn height + y offset
    }
    

    If you want changes in xOrigin too, then take another variable with xOrigin

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

Sidebar

Related Questions

Say we have array of arrays: tree_limbs = Array.new tree_limbs << %w(1 2 3
I have tried this code to copy my data to plist but its not
I have to implement a custom autosuggestion for UITextField> I have an array of
I have array: array( 0 => new SomeClass(1), 1 => new SomeClass(2), 2 =>
I have array INPUTFILES with n files INPUTFILES=( file_0 ... files_n-1 ) And i
I have array of hashes: @array = [{:id => 1, :status=>R}, {:id => 1,
I have array of select tag. <select id='uniqueID' name=status> <option value=1>Present</option> <option value=2>Absent</option> </select>
I have array like this: $path = array ( [0] => site\projects\terrace_and_balcony\mexico.jpg [1] =>
I have array result like this: Array ( [0] => stdClass Object ( [id_global_info]
I have array of strings, String[] data and it's 10 elements has value P

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.