1

i have a view and i want to display a UIViewController with custom size. But i didn't succeed. Here is my code.

var vx = KeyboardViewController()
vx.modalPresentationStyle = UIModalPresentationStyle.FormSheet
vx.preferredContentSize = CGSizeMake(self.view.frame.width, 150)    
self.presentViewController(vx, animated: true, completion: nil)

This UIViewController is displayed in the full screen size

TomSawyer
  • 3,711
  • 6
  • 44
  • 79

1 Answers1

5

You need to give the presented view controller a custom transitioningDelegate, which will then be able to insert a custom UIPresentationController into the presentation process, whose frameOfPresentedViewInContainerView you will have overridden appropriately.

matt
  • 515,959
  • 87
  • 875
  • 1,141
  • Working downloadable example project here: https://github.com/mattneub/custom-alert-view-iOS7 – matt Mar 10 '16 at 19:32
  • I don't understand the code, it's too complex for me. I've seen this answer, but didn't work: http://stackoverflow.com/questions/29219688/present-modal-view-controller-in-half-size-parent-controller . There is no more simple way to present half size uiviewcontroller? – TomSawyer Mar 10 '16 at 19:51
  • 3
    That answer is exactly the same as what I'm telling you _and showing you_ how to do. – matt Mar 10 '16 at 19:53