Refresh/reload 来自数据库的文本视图 |按钮点击功能

Refresh/reload textview from database | Button Tapped Function

我已经声明了 textview 插座:

@IBOutlet weak var messageView: UITextView!

我已经创建了界面动作,并放置了逻辑:

@IBAction func refreshTextViewTapped(sender: UIButton) {

// logic

}

Reload/update 包含新内容的文本视图。

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