Forum Archive

UI-View refuses to present()

chebfarid

Strange problem with a simple view: when I try to present it I receive the error message "View is already being presented or animation is in progress"
Which is definitively not true:
in my project I'm using three UI-files which are loaded when needed and closed when their job is done, for example:

v = ui.load_view('view2')
spin = ui.ActivityIndicator()
v.present('sheet')
v.add_subview(spin)
spin.start()
### several thousand loops which can last 15-30 secs ...
spin.stop()
v.close()
### another view to display the results (in html):
browser = ui.load.view('view3')
### assembly of the html code ...
browser.present('full_screen')
# => ERROR message ...

As you see the animation was stopped and the view was closed, what am I missing?
Thanks for any hint!

omz

Could you try adding something like time.sleep(1) after v.close() (a lower value might work as well)? This could be a bug in the close method, perhaps causing it to return before the animation has finished.

chebfarid

Bingo! :)
I had already thought about inserting a short delay but I first wanted to know if I am using the close() method correctly.
Thank you!