How to force screen refresh for UIScrollView from a thread / function other than UI (iPhone)

I am drawing a set of images on a uiscrollview from a non-ui stream / function. But it is displayed only after all the images are done by drawing. To write all the images, I wrote a function, and this is what is called a non-ui stream. I wrote this line inside a function

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

And wrote the function below

- (void)updateUI
{
[myScrollView setNeedsDisplay];
}

But this has no effect, even when I see that the control is being passed to this function. What will we do?

+3
source share
4 answers

Ok, I have a solution. It works fine, although I don't like the solution. I changed my function as follows.

- (void)updateUI
{
 for(UIView *subview in [myScrollView subviews]) 
 {
  [myScrollView bringSubviewToFront:subview];   
 } 
}
+1
source

, , . , , : -)

+3

Maybe you should also call setNeedsLayoutand / or layoutIfNeeded?

0
source

Try something like performSelectorOnMainThread:withObject:waitUntilDone:

0
source

Source: https://habr.com/ru/post/1728308/


All Articles