当我按下不同的按钮时,如何使 UITextView 的源文本发生变化? 谢谢。
最佳答案
要更改 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";
}
关于iphone - UITextView 更改源文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8417774/