我的应用程序的条目ViewController
包含两个按钮:weight
和age
。在 mainViewController
中,这是单击weight
按钮时运行的代码:
@IBAction func weightSearch(_ sender: Any) {
//Weight button clicked
inputReset()
userInput.keyboardType = UIKeyboardType.numberPad
userInput.becomeFirstResponder()
}
这是单击age
按钮时运行的代码:
@IBAction func ageSearch(_ sender: Any) {
//Age button clicked
inputReset()
userInput.inputView = agePicker
userInput.becomeFirstResponder()
}
我要做的是实现两个 3D Touch 快速操作,一个称为Weight Search
(运行代码func weightSearch
),另一个称为Age Search
(运行代码func ageSearch
)。这是我到目前为止所做的:
- 在
Info.plist
文件中,我创建了一个UIApplicationShortcutItems
数组,其中包含两个Items
字典类型,以及它们各自的UIApplicationShortcutItemTitle
和UIApplicationShortcutItemType
. 在我的
AppDelegate.swift
文件中,我添加了初步的快速操作代码:func application(_ application: UIApplication, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: @escaping (Bool) -> Void) { //3D touch features }
我现在的问题是我不确定要为我的AppDelegate.swift
文件编写什么代码。我看过的所有教程和该站点上的所有类似问题都涉及ViewController
使用快速操作调用不同的函数,而不是在同一个 `ViewController. 先感谢您。