How would one change the position of a Form Sheet Modal View Controller?
By default it is positioned in the centre of the screen, I would like to offset the Form Sheet position so that when I display the keyboard it does not overlap the Form Sheet window.
Is this possible?
You can modify the frame of the parent controller. something like:
CGRect frame = self.parentViewController.view.frame;
frame.origin.x -= 50;
frame.origin.y -= 50;
self.parentViewController.view.frame = frame;
this will move the position of your modal view by (-50,-50)
If you're using a UIViewController and presenting it using presentModalViewController, then you have to accept the default behavior for the type you've specified (form). That's going to land square in the center every time. So the way you're doing it, it isn't possible.
However, it'd be relatively trivial to create your own view and present it yourself by animating it in and out (and performing some work to darken/disable interaction on views situated below), giving you the power to place it wherever you want.
As far as accommodating the keyboard, I suppose I'd consider scrolling the subview you're presenting in the form view to the appropriate offset.
Hope this is helpful.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With