简体   繁体   English

iOS UIInputViewController:呈现自定义UIViewController + NIB

[英]iOS UIInputViewController: present Custom UIViewController + NIB

I've a keyboard extension and want to present a custom UIViewController with a NIB file inside an UIInputViewController. 我有一个键盘扩展,想要在UIInputViewController内提供带有NIB文件的自定义UIViewController。 I already made some custom keyboards with ObjectiveC in the past. 过去,我已经使用ObjectiveC制作了一些自定义键盘。 There I could set a UiNavigationController to the UIInputViewController. 在那里,我可以将UiNavigationController设置为UIInputViewController。 But it seems that this is not possible anymore. 但这似乎不再可行。

  • Does anyone knows how to do that? 有谁知道该怎么做?
  • Or does anyone knows a good tutorial? 还是有人知道一个好的教程?

Here is some sample code that doesn't work. 这是一些无效的示例代码。

class KeyboardViewController: UIInputViewController {

override func viewDidLoad() {
    super.viewDidLoad()
    let controller: MyViewController = MyViewController()
    self.present(controller, animated: false, completion: nil)
}

...
}

I have solved my problem: 我已经解决了我的问题:

I just put the code into viewDidAppear instead of viewDidLoad 我只是将代码放入viewDidAppear而不是viewDidLoad

override func viewDidAppear(_ animated: Bool) {
    let controller: MyViewController = MyViewController()
    self.present(controller, animated: false, completion: nil)
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何实例化自定义iOS UIViewController并在Storyboard下使用它的NIB? - How to instantiate a custom iOS UIViewController and use it's NIB under Storyboard? iOS从多个UIViewController的Nib文件实例化自定义视图 - iOS Instantiate Custom View from Nib File across multiple UIViewController iOS自定义键盘增加UIInputViewController高度 - iOS Custom keyboard increase UIInputViewController height iOS6:UIViewController无法加载名为的nib - iOS6: UIViewController was unable to load nib named 在Swift中将自定义UITableViewCell从笔尖加载到UIViewController - Loading a Custom UITableViewCell from nib to a UIViewController in Swift UIInputViewController键盘未在iOS 8中显示 - UIInputViewController keyboard not displaying in iOS 8 iOS 9 UIInputViewController 关闭键盘 - iOS 9 UIInputViewController dismissKeyboard iOS自定义UIViewController错误 - IOS Custom UIViewController Error 如何通过自定义UICollectionViewCell NIB呈现popoverPresentationController - How to present a popoverPresentationController from custom UICollectionViewCell NIB 在情节提要中向从nib加载的自定义类UIViewController添加子视图 - Add a subview to a custom class UIViewController that loads from nib, in Storyboard
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM