Re: presentViewController completion block usage
Re: presentViewController completion block usage
- Subject: Re: presentViewController completion block usage
- From: Roland King <email@hidden>
- Date: Fri, 12 Apr 2013 22:00:31 +0800
On 12 Apr, 2013, at 9:50 PM, Koen van der Drift <email@hidden> wrote:
>
> On Apr 12, 2013, at 9:30 AM, Roland King <email@hidden> wrote:
>
>> Did you have a particular use-case in mind?
>
> I am using the modalVC to set/change parameters for a calculation. These parameters are properties of the presentingVC, which also has a 'Start Calculation' button. So when I open the modalVC, the textfields need to show the current values of the parameters. When I close it, the values need to go back to the properties of the presentingVC. So using the completion block to pass these values around seemed like a good idea.
>
> - Koen.
As I said, not really, that block isn't called until the presenting VC is entirely on-screen, the other VC has been dismissed, all the animations are finished etc. Normally if you want to pass information back to the presenting VC you want to do it before the transition even starts, so the VC configures itself to display that information and then comes on-screen with it already showing. If you use the completion block, the presenting VC will come back on-screen showing whatever it showed when it went off-screen and then, an amount of time later, when the animations are done and the system decides the presented VC is now really, fully, off-screen and it feels like calling the completion block (no guarantees when that is) then you'll get the information and only then will you update the screen, so the sequence would be
dismiss-come back on screen showing stale information-wait-get callback from dismissed controller-change to show new information.
In most normal cases you want the sequence
dismiss-get callback from dismissed controller-change to show new information when offscreen-come back on screen showing correct information.
The completion block is really for your view controller to know when it is entirely finished presenting or entirely finished dismissing a view controller so that it can do some cleanup work, if it needs to. They often don't.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden