从数据库刷新/重新加载textview |按钮抽头功能

时间:2015-02-15 21:07:10

标签: ios database textview refresh reload

我已宣布textview outlet:

@IBOutlet weak var messageView: UITextView!

我创建了界面操作,并放置逻辑:

@IBAction func refreshTextViewTapped(sender: UIButton) {

// logic

}

使用新内容重新加载/更新textview。

1 个答案:

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