UITextView setText does not update text

In my nib, I have a UITextView component.

In my code, I have a UITextView field and I used Interface Builder to make sure they are connected (at least I think I did this by dragging it from the β€œFile Owner” and dropping it onto the UITextView in the Interface Builder and select my member variable).

Now when I update the text through setText , the UITextView is still empty.

Thanks DeShawn

+6
source share
3 answers

do you use

  @property(nonatomic,retain) UITextView *yourTextViewName; 

then

  @synthesize yourTextViewName; 

in the .m file?

If so, use the following code in viewDidLoad after updating the value to verify:

  NSLog(@"Text View Value = %@",yourTextViewName.text); 
+4
source

If this has not yet been clarified; check out iOS Text View Not Updating

The reference to yourTextViewName should be IBOutlet UITextView *yourTextViewname Then add @property (nonatomic, retain) UITextView *yourTextViewName . Add @synthesize yourTextViewName to the corresponding .m file.

To set the text, use

 yourTextViewName.text = @"some text"; 
+3
source

It might seem crazy, but I had to explicitly set the hidden UITextView property to NO in the code, and then it started to display. See if this works for you.

0
source

Source: https://habr.com/ru/post/891686/


All Articles