我已宣布textview outlet:
@IBOutlet weak var messageView: UITextView!
我创建了界面操作,并放置逻辑:
@IBAction func refreshTextViewTapped(sender: UIButton) {
// logic
}
使用新内容重新加载/更新textview。
答案 0 :(得分:0)
是不是setText函数会自动更新textview?如果文本已经更新,您需要重新加载函数吗?
- (void)viewDidLoad()
{
setMyTextView();
// create the button that calls your function to update the text view
UIButton *myButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 100, 44);
[myButton addTarget:self action:@selector(setMyTextView) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:myButton];
}
- (void)setMyTextView()
{
NSString *myText = // value that is returned from the database query;
[self.myTextView setText:myText];
}