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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:22:33+00:00 2026-06-13T20:22:33+00:00

I want to create an alertview with two uitextfields inside of it. method: //show

  • 0

I want to create an alertview with two uitextfields inside of it.

method:
//show alertview for file input
- (IBAction)showAddFiles:(id)sender {
    UIAlertView *message = [[UIAlertView alloc] initWithTitle:@"Enter File Details"
                                                      message:nil
                                                     delegate:self
                                            cancelButtonTitle:@"Cancel"
                                            otherButtonTitles:@"Add", nil];



    UITextField *textFieldDescription = [message textFieldAtIndex:0];
    textFieldDescription.placeholder = @"File Description : Ex. Acat Briefing";
    UITextField *textFieldFileName = [message textFieldAtIndex:1];
    textFieldFileName.placeholder = @"Exact File Name : Ex. acat.pdf";


    [message show];
}


//make sure file description is long enoguh
- (BOOL)alertViewShouldEnableFirstOtherButton:(UIAlertView *)alertView
{
    NSString *inputText = [[alertView textFieldAtIndex:0] text];

    if( [inputText length] <= 15 && [inputText length] >= 4)
    {
        return YES;
    }
    else
    {
        return NO;
    }
}

//handle add button
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    NSString *title = [alertView buttonTitleAtIndex:buttonIndex];
    if([title isEqualToString:@"Add"])
    {
        UITextField *fileDescription = [alertView textFieldAtIndex:0];
        UITextField *fileName = [alertView textFieldAtIndex:1];
        NSLog(@"Desc: %@\nName: %@", fileDescription.text, fileName.text);
    }
}

Error:

* Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘textFieldIndex (0) is outside of the bounds of the array of text fields’

Why I do get this error, how can I create two uitextfields in an alert view?

=========Working Solution ===========
Thanks for the answer below works when you only need two plain textfields

//show alertview for file input
- (IBAction)showAddFiles:(id)sender {
    UIAlertView *message = [[UIAlertView alloc] initWithTitle:@"Enter File Details"
                                                      message:nil
                                                     delegate:self
                                            cancelButtonTitle:@"Cancel"
                                            otherButtonTitles:@"Add", nil];



    [message setAlertViewStyle:UIAlertViewStyleLoginAndPasswordInput];
    UITextField *fileDescription = [message textFieldAtIndex:0];
    fileDescription.placeholder=@"Ex. acat.pdf";
    [[message textFieldAtIndex:1] setSecureTextEntry:NO];
    UITextField *fileName= [message textFieldAtIndex:1];
    fileName.placeholder=@"Ex. Acat Briefing";

    [message show];
}
  • 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-13T20:22:34+00:00Added an answer on June 13, 2026 at 8:22 pm

    After you allocated the “message” alert view. Add this to your code:

    [message setAlertViewStyle:UIAlertViewStyleLoginAndPasswordInput];
    [[message textFieldAtIndex:1] setSecureTextEntry:NO];
    

    This will make your alert view two text field inside.

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

Sidebar

Related Questions

In C# code, I want create a log file for each each method in
I want to create a new field (or two) in my table that is
I want create a pdf using iText. The method which does this is a
I want create a generic (general) method which accepts the return types of LINQ
I want create a tarball that when extracted the file(s) will be placed at
I want create own SetupTypeDlg using wix default dialogs to show the disk costs
I want create a div container with a message for first time visitors to
I want create connection string in web.config file with CredentialCache.DefaultCredentials , it's possible and
i want create XML file here is my following code String fileName = jasstech.xml;
I want create simple puzzle to select random 5 names from input. Lets say

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.