#StackBounty: #ios #swift #uitextview Change UITextView text by using its tag number to identify the element due for change

Bounty: 50

//UITextView Creation
let textarea  = UITextView (frame : CGRect (x: 40, y: 100 ,width:100 , height:100))
                                            textarea.delegate = self
                                            textarea.tag = self.numarr
                                            textarea.backgroundColor = UIColor(red: 0.9686, green: 0.9686, blue: 0.9686, alpha: 1.0)
                                            textarea.layer.cornerRadius = 20.0
                                            textarea.contentInset = UIEdgeInsetsMake(5, 5, 5, 5);
                                            textarea.layer.masksToBounds = true

//Later after, the button function
 @IBAction func loadbutton(_ sender: Any) {

if let hellatextview = self.scrollviewxp.viewWithTag(index) as? UITextView

                            hellatextview.text = "success"


The above code is not flagged as an error on Xcode but doesn’t change the UITextView (hellatextview) value upon execution. A textView with the tag number (index) exists but isn’t being changed.

Any ideas why it isn’t working? Ive had the same issue with UIButtons

Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.