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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:38:01+00:00 2026-05-27T22:38:01+00:00

I am working on an app that has multiple UITextView s with a custom

  • 0

I am working on an app that has multiple UITextViews with a custom keyboard and then some custom menu options that will insert predefined text. Is there a way to use a variable for a UITextView?

The code below works great but I need to use the custom keyboard/buttons for more than just one UITextView.

- (IBAction)textBTN:(id)sender {
    textView1.text = [textView1.text stringByAppendingString:@"myAsciiString"];
}

I will also have textView2, textView3, etc.

  • 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-27T22:38:02+00:00Added an answer on May 27, 2026 at 10:38 pm

    You can add your text fields into an array and modify their properties in a loop:

    NSArray *textViews= [NSArray arrayWithObjects:textView1, textView2, textView3, nil];
    for(UITextView *txtView in textViews)
       txtView.text = [txtView.text stringByAppendingString:@"myAsciiString"];
    
    [textViews release];
    

    Edit

    If you wish to know which textView initiated the action (assuming you connected multiple textViews to the same IBAction), you could either set and check the tag of the view, or you can compare with an instance:

    textView1.tag = 0;
    textView2.tag = 1;
    textView3.tag = 2;
    //etc.
    
    - (IBAction)someTextViewAction:(id)sender {
        //Option 1
        if (sender.tag == 0)
           textView1.text = [textView1.text stringByAppendingString:@"myAsciiString"];
        else if(sender.tag == 1)
           textView2.text = [textView2.text stringByAppendingString:@"myAsciiString"];
        else if(sender.tag == 2)
           textView3.text = [textView3.text stringByAppendingString:@"myAsciiString"];
    
        //Option 2
        if ([sender isEqual:textView1])
           textView1.text = [textView1.text stringByAppendingString:@"myAsciiString"];
        else if ([sender isEqual:textView2])
           textView2.text = [textView2.text stringByAppendingString:@"myAsciiString"];
        else if ([sender isEqual:textView3])
           textView3.text = [textView3.text stringByAppendingString:@"myAsciiString"];
    
    }
    

    If you wish to assign a value to the active text view, you could iterate through your subviews and if it has first responder, set the value:

    - (IBAction)someButtonAction:(id)sender {
    
        for (UIView *view in self.subviews)
        {
                if ([view isKindOfClass:[UITextView class]])
                {
                    if ([view isFirstResponder])
                    {
                            view.text = [view.text stringByAppendingString:@"myAsciiString"];
                    }
                }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on an Android app that has multiple screens the user will
I am working on a C++ app which internally has some controller objects that
I am working on an app that has multiple tabs. In the first tab
I am working on an app that has multiple edittext fields and spinners and
I'm working on a rails app that has a whole bunch of before filters
I'm working on a PHP app that has several objects that can be commented
I am working on a simple app tab-bar based application that has two views.
I am working on an existing ASP.NET MVC app that started small and has
I'm working for a company that has already released an app on the store.
I'm working on a web-app, in which each user has multiple non-local XML files

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.