0

How would I make the source text of a UITextView change whenever I press different buttons? Thanks.

Jeeter
  • 5,887
  • 6
  • 44
  • 67

2 Answers2

3

To change the text of a UITextView, set its text property:

textView.text = @"your text here";

You can call this from within a button's selector like so:

UIButton *yourButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[yourButton setTitle:@"click to change textview's text" forState:UIControlStateNormal];
[yourButton addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];

...

- (void)buttonClicked:(id)sender {

    textView.text = @"your text";
}
Mutix
  • 4,196
  • 1
  • 27
  • 39
0

just create different methods which changes the UITextView values. Connect it the correct way in IB to the textView and you're done.

Foo
  • 596
  • 2
  • 5
  • 21