Search code examples
iosiphoneuiviewcontrollerios7childviewcontroller

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


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.


Solution

  • 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...