开发者

refreshing contents of UITextView

开发者 https://www.devze.com 2023-03-11 07:02 出处:网络
I have a textview which contains chat history obtained from a server.The cha开发者_开发知识库t history is being constantly updated through a thread which I had started in a previous view. My problem i

I have a textview which contains chat history obtained from a server.The cha开发者_开发知识库t history is being constantly updated through a thread which I had started in a previous view. My problem is how do I constantly update my UITextView to reflect the changes?

self.textView.text = [[NSString alloc]initWithFormat:@"%@",chatHistory];


I use something like this:

NSString *newMessage = [NSString stringWithFormat:@"%@\n%@", [textView text], newChat];
[textView setText:newMessage];

also make sure your GUI updates are on the main application thread.

[self performSelectorOnMainThread:@selector(updateMyGui) withObject:nil waitUntilDone:NO];
0

精彩评论

暂无评论...
验证码 换一张
取 消