On Jun 10, 2010, at 02:28, Alec Stewart wrote:
> 1. The main window and the box resize to fit the view I am swapping in but
> after the resizing is complete, the box is empty and none of the UI elements
> (e.g label, progress bar, etc...) contained in the new view are visible.
>
> 2. The routine I call after displayViewController runs.
>
> 3. The UI elements of the new view become visible.
>
> I need to find a way to swap the order of steps 2 and 3.
There are 2 things going on here. First, when you swap in your new subview,
drawing of the new contents is going to be consolidated into the next window
display update, which occurs at the next iteration of the run loop. If you
invoke your post-switching method immediately after the switch, it will run
before the new contents have actually been drawn.
In addition, you've asked to animate the window size change, but then changed
the window contents before the animation has had a chance to run. I don't know
what's supposed to happen in such circumstances, but it's quite possible the
animation is running to completion with the box contents as they were at the
time of the start of the animation (i.e. nothing), after which the real
contents of the window are drawn.
One hacky solution is just to delay your method invocation until window
updating is done, either:
[self performSelector: @selector (myPostSwitchingMethod) withObject:
nil afterDelay: 0];
if deferring until the next run loop iteration is enough, or:
[self performSelector: @selector (myPostSwitchingMethod) withObject:
nil afterDelay: 0.25];
if you need to wait for the resize animation to complete. (The default
animation run time is 1/4 sec.)
A more reliable solution may be somewhat harder, but it depends on what your
real intention is -- why you need your post-switching method to be deferred
until the new subview appearance is completely drawn.
_______________________________________________
Cocoa-dev mailing list ([email protected])
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]