开发者

How to change the position of a Form Sheet Modal View Controller

开发者 https://www.devze.com 2023-04-10 16:05 出处:网络
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 lik开发者_高级运维e to offset the Form Sheet position so that

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 lik开发者_高级运维e 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号