Presenting a modal view controller without covering the current view on iPhone

Mazen Kasser picture Mazen Kasser · Dec 5, 2013 · Viewed 10.3k times · Source

enter image description here

I have been trying to add view container with leaving 20px space from the sides. But it seems not the proper way of doing it...

// ADD CHILD VIEW CONTROLLER
    [parentViewController addChildViewController:childViewController];
    [parentViewController.view addSubview:childViewController.view];
    [childViewController didMoveToParentViewController:parentViewController];

// REMOVE THE CHILD VIEW CONTROLLER
    [childViewController willMoveToParentViewController:nil];
    [childViewController view] removeFromSuperview];
    [childViewController removeFromParentViewController];

UPDATE I have figured it out by using this MZFormSheetController "https://github.com/m1entus/MZFormSheetController" Form presentation with cool view transitions.

Answer

Mazen Kasser picture Mazen Kasser · May 1, 2014

Use MZFormSheetController "https://github.com/m1entus/MZFormSheetController" Form presentation with cool view transitions. Or, iOS 8 and above, you can use viewController.modalPresentationStyle = UIModalPresentationOverCurrentContext; Good luck, let me know if you want a full snippet...