How to get notified when a form sheet (UIModalPresentationFormSheet) has disappeared?

I have a view controller (A), which is another view controller (B) as a form sheet (UIModalPresentationFormSheet).

Now I want to reject view controller B and present the other as soon as it is safe (because you cannot use presentModalViewController: while another view controller is displayed or rejected.)

However, I cannot find a way to get notified when the form sheet completely disappears. Any solutions?

+4
source share
2 answers

So here is what we did.

Since the view manager that manages the form table (B) gets -viewDidDisappear , we simply add the view controller (A) as a delegate, which we then manually notify when -viewDidDisappear is called on (B).

The delegate definition is as follows:

  @protocol FormSheetViewControllerDelegate
 - (void) formSheetViewDidDisappear;
 @end

We add a delegate to the FormSheetViewController:

  @interface FormSheetViewController

 @property (nonatomic, assign) id <FormSheetViewControllerDelegate>

 @end

And we call -formSheetViewDidDisappear from FormSheetViewController:

  @implementation FormSheetViewController

 - (void) viewDidDisappear: (BOOL) animated {
     [registerViewControllerDelegate registerViewControllerDidDisappear];
 }

 @end

PS :. Starting with iOS 5 and blocks, the UIViewController has a method

  - (void) dismissViewControllerAnimated: (BOOL) flag completion: (void (^) (void)) completion 
What could you use to react to the dismissal of the form sheet form.
+2
source

As you already noticed, the old viewDidAppear methods viewDidAppear not start when the UIModalPresentationFormSheet controller UIModalPresentationFormSheet rejected. You can emulate a viewWillAppear call simply by calling this method when you reject the controller, but that is not what you need.

Instead of presenting a second modal view controller, can you direct your new viewController to an existing modal viewController navigation manager? In any case, this can give a nice user interface.

Or can you use a popover?

+3
source

All Articles