11

我目前正在通過擴展爲iOS 8構建自定義鍵盤。當用戶按下鍵盤視圖上的某個按鈕時,我想呈現一個全屏幕模式視圖控制器。當我嘗試呈現視圖控制器時,它會嘗試呈現在鍵盤視圖的範圍內。我正在使用[self presentViewController:animated:completion:]與實例化的視圖控制器。無論如何要呈現全屏視圖控制器?類似照片編輯擴展(這顯示全屏視圖控制器)從UIInputViewController顯示全屏視圖控制器

謝謝

+0

你是什麼意思「呈現全屏視圖控制器?」您展示的視圖控制器的框架是否與窗口的框架不匹配? – JAL

回答

0

你必須從所謂的鍵盤,而不是從鍵盤本身的控制器出示您的viewController。

嘗試:

[self.parentViewController presentViewController:animated:completion:] 
+0

我也嘗試過,沒有用:/ UIInputViewController(鍵盤)只是拒絕呈現一個全屏視圖控制器,它似乎.... – virindh

+0

關閉鍵盤,呈現您的視圖控制器,做你必須做的,解僱它並再次顯示鍵盤 –

+0

我認爲你誤解了這個問題......我正在構建一個自定義鍵盤,這將在整個系統的其他應用程序中。這意味着我不能解僱鍵盤並執行代碼。 – virindh

3

應該提高鍵盤的高度,然後出示您的視圖控制器。嘗試這樣的:

- (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:^{ 

     }]; 
} 
相關問題