I am trying to implement a button to trigger the original text I have in the UItextView. I have looked at this post: Trigger button to change text in UITextView in swift3 xcode 8 ios 10
and followed it I realized it only worked for UItextField. Since I need to wrap the my text, I am wondering is that possible to do the similar action with UItextView?
Currently, I have:
@IBOutlet var Textfield: UITextView!
@IBOutlet var ChangingText: [UIButton]!
@IBAction func ChangingTextTapped(_ sender: Any) {
Textfield.text = "Changing text here"
}
But I got the following error:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayM setText:]: unrecognized selector sent to instance 0x282d15b90'
Thanks in advance!
Solution: It works well following the suggestion from Dejan Atanasov:
@IBOutlet var Textfield: UITextView!
@IBOutlet var ChangingText: UIButton!
@IBAction func ChangingTextTapped(_ btn: UIbutton) {
Textfield.text = "Changing text here"
}`