I have the following problem:
I want that the user make a download when pressing a button. During this download, I want to hide the other buttons (which would open the downloaded files, so I want to ensure that no one tries to open files when the update haven’t finished yet).
Is it possible to hide these buttons during this process?
So what I have tried and experienced so far:
- Changes to the buttons I get always just at the end (when it isn’t necessary anymore, because then the update is done).
I tried the following (Pseudocode):
-(void)updatingprogress
{
buttona.hidden=TRUE;
}
-(void)updatingfinished
{
buttona.hidden=FALSE;
}
updateFiles()
{
[self updatingprogress]
... make downloads...
[self updatingfinished]
}
So with logging I see, that I get in my functions at the moment I want, but the changes of the buttons aren’t done during “updatingprogress”. Any Idea how to solve this problem?
Thanks and best regards!
Another possibility is that you’re doing all the work on the main thread, but failing to allow for the fact that, as a rule, UIKit changes don’t take effect until you drop down to the runloop.
The background logic is that you don’t want partial changes to be visible, so e.g. if you wrote:
What you explicitly don’t want is for the word ‘Failure’ to appear in green, then for the word to change to ‘Success’. You want the two changes to occur atomically. Apple achieve this by batching UIKit updates together and effecting them outside of any of your scheduled methods.
So if you have a function on the main thread that does some UI changes, does some work and then undoes the UI changes, but all without at any point exiting to the runloop, then the changes will never be seen.
The quickest solution would be: