Question

I want to present a modalViewController with a small frame and at the center of the view.

Is that possible?

Even if I set some frame to the viewController object, presentModelViewController is displaying that view in full screen mode.

Also, I have used modalPresentationStyle as UIModalPresentationFormSheet. I want to have frame even smaller than that.

How to do that?

Was it helpful?

Solution

You cannot present a modal view controller that has a smaller frame size.

what you can try doing is to set the background of your modal view controller to transparent and then add the smaller sized view in the center (or where ever you wish to have it seen).

OTHER TIPS

Presenting a modal view will cover the entire view, if you don't wish to cover the entire view then you should create the view yourself, add it to the current view as a subView and then animate its transition yourself. It would not be a separate viewController because you're still operating within the bounds of the original view.

Yes. It is possible. Please follow below steps:

- (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];
}

You have to set frame of present controller after your controller setting (just before viewDidLoad method end).

Here I have considered iPad present view controller frame.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top