gpt4 book ai didi

iOS 应用程序/键盘插件无效

转载 作者:行者123 更新时间:2023-11-28 16:17:47 25 4
gpt4 key购买 nike

所以我一直在承担学习Swift和XCode接口(interface)的任务,以进入iOS开发。为此,我一直在练习一些项目,这些项目将帮助我了解所有这些,因此我开始了一个制作自定义键盘的项目。但是,由于我猜测这些教程是用旧版本的 Swift/XCode 编写的,所以我不断收到错误,尤其是一个错误。

每当我进入“设置”并添加我的自定义键盘时,我都会使用它,每当我在键盘切换器中切换它时,键盘崩溃并默认返回到原始 iOS 键盘(这在模拟器和我的手机上都会发生. 另外,目标 iOS 是正确的)。在那次崩溃后,我得到了这个错误:

plugin CalculatorKeyboard plugin myName.CalculatorKeyboard.Calculator interrupted
plugin CalculatorKeyboard plugin myName.CalculatorKeyboard.Calculator invalidated

我目前使用的代码:

class KeyboardViewController: UIInputViewController {

var customInterface: UIView!

override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)

let nib = UINib(nibName: "Calculator", bundle: nil)
let objects = nib.instantiateWithOwner(self, options: nil)
customInterface = objects[0] as! UIView
}

override func viewDidLoad() {
super.viewDidLoad()
view.addSubview(customInterface)
}
}

旧代码:

// var customInterface: UIView!

override func viewDidLoad() {
super.viewDidLoad()
loadInterface()
}

func loadInterface() {
let calculatorNib = UINib(nibName: "Calculator", bundle: nil)
let objects = calculatorNib.instantiateWithOwner(self, options: nil)
view = objects[0] as! UIView
}

我希望在这方面能得到一些帮助,因为我无法在 Google 上找到任何答案。谢谢你! :)

注意:如果我可以使用旧代码,我会更愿意,因为它在其自身的功能中更清晰。

最佳答案

这会起作用

override func viewDidLoad() {
super.viewDidLoad()
let nib = UINib(nibName: "KeyboardView", bundle: nil)
let objects = nib.instantiateWithOwner(self, options: nil)
view = objects[0] as! UIView;

}

还有一个很好的演示应用程序,它是用 swift 和 objective-C 编写的 https://github.com/iManiaq/ios-color-keyboard

编辑 去设置->通用->键盘在那里你添加你的键盘

enter image description here

在此输入图片描述

enter image description here

关于iOS 应用程序/键盘插件无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38893870/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com