我想在UITextview中写一些日志文本。例如:加载X图像,创建y对象等。我的问题是:插入一行后,UITextView不会刷新。我认为当插入结束时,所有新文本都会同时显示。
append = [@"" stringByAppendingFormat:@"\n%@ file is dowloading...", refreshName]
logTextView.text = [logTextView.text stringByAppendingString: append];下载后,我保存文件
append = [@"" stringByAppendingFormat:@"\n%@ file saved", refreshName];
logTextView.text = [logTextView.text stringByAppendingString: append];我试过了
[logTextView setNeedsDisplay]或
[logTextView performSelectorOnMainThread:@selector(setNeedsDisplay) withObject:nil waitUntilDone:YES];但没有用:
会议将是:
发生的情况是:
发布于 2012-08-28 12:54:04
文本将只在下一次通过主线程的运行循环进行更新。如果主循环上有一个长时间运行的任务,并且它一直在写入textView,那么在任务结束之前不会显示任何内容。
我可以想出几种方法来解决这个问题:
当doTask1完成时,它会分发下一个块:
dispatch_async(dispatch_get_main_queue(), ^
{
update textView text again;
[self doTask2:maybeSomeDictionary];
}当最后的任务完成后,你就完成了。
https://stackoverflow.com/questions/12153939
复制相似问题