Display fullscreen view controller from UIInputViewController
Asked Answered
I

2

11

I'm currently building a custom keyboard for iOS 8 though extensions. When the user presses a certain button on the keyboard view, I want to present a full screen modal view controller. When I try to present the view controller, it tries to present within the bounds of the keyboard view. I'm using [self presentViewController:animated:completion:] with an instantiated view controller. Is there anyway to present a full screen view controller? akin to photo editing extensions(which display a full screen view controller)

Thank you

Isolde answered 18/6, 2015 at 16:7 Comment(1)
What do you mean "present a full screen view controller?" Does the frame of the view controller you're presenting not match the frame of the window?Stymie
S
3

You should Increase height of your keyboard and then present your View Controller. Try something like this:

- (void) presentVC{
         NSLayoutConstraint *_heightConstraint = [NSLayoutConstraint constraintWithItem:self.view
                                                         attribute:NSLayoutAttributeHeight
                                                         relatedBy:NSLayoutRelationEqual
                                                            toItem:nil
                                                         attribute:NSLayoutAttributeNotAnAttribute
                                                        multiplier:1.0
                                                          constant:[UIScreen mainScreen].bounds.size.height];

        [self.view addConstraint: _heightConstraint];

        TestViewController *test = [[TestViewController alloc] initWithNibName:@"TestViewController" bundle:nil];
        [self presentViewController:test animated:YES completion:^{

        }];
}
Subkingdom answered 26/6, 2015 at 8:39 Comment(0)
E
0

You have to present your viewController from the controller that called the keyboard, not from the keyboard itself.

Try:

[self.parentViewController presentViewController:animated:completion:]
Epiphytotic answered 23/6, 2015 at 10:12 Comment(4)
I tried that too, with no avail :/ UIInputViewController(the keyboard) simply refuses to present a full screen view controller it seems....Isolde
Dismiss the keyboard, present your view controller, do what you have to do, dismiss it and show the keyboard againEpiphytotic
I think you misunderstood the question...I'm building a custom keyboard and this is going to be in other applications throughout the system. This means that I can't dismiss the keyboard and execute code.Isolde
Maybe you could try to add a subview to your keyboard with the frame of the window. (Don't forget to [keyboard setClipsToBounds:No])Epiphytotic

© 2022 - 2024 — McMap. All rights reserved.