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.
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...
You can try Something like,
DetailViewController *viewController= [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil];
viewController.modalPresentationStyle=UIModalPresentationFormSheet;
viewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentViewController:viewController animated:YES completion:^{
viewController.view.superview.frame = CGRectMake(0, 0, 310, 500);
viewController.view.superview.center = self.view.center;
}];
Set superview.frame
and modalTransitionStyle
according to you.
The better way is to have your own controller and view.
On the main controller use the present view controller.
[self presentViewController:myController animated:YES completion:nil];
On the viewDidLoad adjust myController frame.
CGRect newFrame = self.view.frame;
newFame.size.width -= 40;
newFame.size.height -= 40;
newFrame.origin.x = 20;
newFrame.origin.y = 20;
self.view.frame = newFrame
Adding as childViewController is for view controller containment, when you want a single controller with multiples views, each with its own controller.
You're on a right way. But you have to add container view permanently on a storyboard, then you can just show/hide it by setHidden:
method.
Also you can show second controller animated by this method.
On iPhone and iPod touch, the presented view is always full screen. So, it can't be presenting a non-full screen view controller.
Don't presenting the view controller, add the view controller's view as a subview to the parent view controller. So, you can control the appearance, even the shadow layer under it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.