iphone - UITextView 更改源文本

标签 iphone ios textview uitextview

当我按下不同的按钮时,如何使 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/

相关文章:

iphone - 如何在 iOS 中为 UIImage 像素化/添加像素化效果

iphone - NS文件管理器 : hide a folder?

ios - NSFileHandle 写数据 : exception handling

iphone - iOS 初学者 : NSMutableArray + int variable for storing array index position (Where is the connection)

iphone - iPhone 3G 上的坐标全错了?这可能是你的编译器

ios - 换行时出现弹跳

ios - Xcode - 使用约束来放置不完全水平居中的项目

Android 文本大小以编程方式太大

android - 您必须为 TextView android 错误提供资源 ID

android - 防止设备文本大小的文本大小更改