PresentModalViewController与一些框架

我想提出一个小框架的modalViewController在视图的中心。

那可能吗?

即使我将一些框架设置为viewController对象,presentModelViewController以全屏模式显示该视图。

另外,我使用了modalPresentationStyle作为UIModalPresentationFormSheet 。 我想要比这更小的框架。

怎么做?

不能呈现具有较小帧尺寸的模式视图控制器。

你可以尝试的做法是将你的模式视图控制器的背景设置为透明,然后在中心(或者你希望看到的地方)添加较小尺寸的视图。

呈现模式视图将覆盖整个视图,如果您不希望覆盖整个视图,则应该自己创build视图,将其作为子视图添加到当前视图,然后自行为其转换设置animation。 它不会是一个单独的viewController,因为你仍然在原始视图的范围内运行。

是。 有可能的。 请按照以下步骤操作:

 - (void)viewDidLoad { [super viewDidLoad]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShown:) name:UIKeyboardWillShowNotification object:nil]; CGRect rect = CGRectMake(242, 60, 540, 312); self.controller.view.superview.frame = [self.view convertRect:rect toView:self.controller.view.superview.superview]; } - (void)keyboardWillShown:(NSNotification*)aNotification { CGRect rect = CGRectMake(242, 60, 540, 312); self.controller.view.superview.frame = [self.view convertRect:rect toView:self.controller.view.superview.superview]; } 

您的控制器设置完成后(您必须在viewDidLoad方法结束之前)设置当前控制器的框架。

在这里我已经考虑iPad目前的视图控制器框架。