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.
You can add your text fields into an array and modify their properties in a loop:
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:
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: