Iphone UITextView更改源文本

Iphone UITextView更改源文本,iphone,ios,textview,uitextview,Iphone,Ios,Textview,Uitextview,当我按下不同的按钮时,如何更改UITextView的源文本? 谢谢。只需创建不同的方法即可更改UITextView值。在IB中以正确的方式将其连接到textView,就完成了 只需创建更改UITextView值的不同方法即可。在IB中以正确的方式将其连接到textView,就完成了 要更改UITextView的文本,请设置其text属性: textView.text=@“您的文本在此” 您可以从按钮的选择器中调用它,如下所示: UIButton *yourButton = [UIButton b

当我按下不同的按钮时,如何更改UITextView的源文本?
谢谢。

只需创建不同的方法即可更改UITextView值。在IB中以正确的方式将其连接到textView,就完成了

只需创建更改UITextView值的不同方法即可。在IB中以正确的方式将其连接到textView,就完成了

要更改
UITextView
的文本,请设置其
text
属性:

textView.text=@“您的文本在此”

您可以从按钮的选择器中调用它,如下所示:

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";
}

要更改
UITextView
的文本,请设置其
text
属性:

textView.text=@“您的文本在此”

您可以从按钮的选择器中调用它,如下所示:

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";
}

如何在不更改字体和属性的情况下更改文本?@AlbertCatalá:您可能遇到此错误:如何在不更改字体和属性的情况下更改文本?@AlbertCatalá:您可能遇到此错误: