Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITextView setText is not updating the text

In my nib, I have a UITextView component.

In my code I have a UITextView field and I have used Interface Builder to make sure that the two are connected (at least I think I did that by dragging from "Files Owner" and dropping it on the UITextView in Interface Builder and selecting my member variable).

Now, when I update the text via setText, the UITextView still remains blank.

Thanks DeShawn

like image 791
user605957 Avatar asked Jun 29 '11 23:06

user605957


2 Answers

Have you used

  @property(nonatomic,retain) UITextView *yourTextViewName;

then

  @synthesize yourTextViewName;

in .m file?

If yes, use the following code in viewDidLoad after updating the value to check:

   NSLog(@"Text View Value = %@",yourTextViewName.text);
like image 84
Oras Avatar answered Nov 11 '22 20:11

Oras


If it isn't figured it out yet; check out iOS Text View Not Updating

The referencing yourTextViewName must be an IBOutlet UITextView *yourTextViewname Then add the @property (nonatomic, retain) UITextView *yourTextViewName. Add the @synthesize yourTextViewName in the corresponding .m file.

To set the text, use

yourTextViewName.text = @"some text";
like image 42
erleyo Avatar answered Nov 11 '22 18:11

erleyo