当前位置:网站首页>[Swift] Customize the shortcut that pops up by clicking the APP icon
[Swift] Customize the shortcut that pops up by clicking the APP icon
2022-07-31 03:32:00 【The wind is light and the moon is bright】
开发中的APP,不做任何处理,Click the shortcut that pops up.
上线的APP,不做任何处理,Click the shortcut that pops up.
自定义快捷方式
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
setupShortcutItems()
}
import Foundation
extension AppDelegate {
func setupShortcutItems() {
let searchIcon = UIApplicationShortcutIcon(type: .search)
let searchItem = UIApplicationShortcutItem(type: "search", localizedTitle: "搜索", localizedSubtitle: nil, icon: searchIcon, userInfo: nil)
let messageIcon = UIApplicationShortcutIcon(type: .message)
let messageItem = UIApplicationShortcutItem(type: "message", localizedTitle: "消息", localizedSubtitle: "Message subtitle", icon: messageIcon, userInfo: nil)
UIApplication.shared.shortcutItems = [searchItem, messageItem]
}
func application(_ application: UIApplication, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: @escaping (Bool) -> Void) {
if (shortcutItem.type == "search") {
print("进入搜索")
} else if (shortcutItem.type == "message") {
print("incoming message")
}
}
}
边栏推荐
- 观察者模式
- 《DeepJIT: An End-To-End Deep Learning Framework for Just-In-Time Defect Prediction》论文笔记
- Getting Started with CefSharp - winform
- How to develop a high-quality test case?
- els 方块向左移动条件判断
- 组件传值 provide/inject
- Golang中的addressable
- Select the smoke test case, and make the first pass for the product package entering QA
- 注解用法含义
- BP神经网络
猜你喜欢

Unity2D 自定义Scriptable Tiles的理解与使用(四)——开始着手构建一个基于Tile类的自定义tile(下)

【动态规划】连续子数组的最大和

TCP详解(三)

LeetCode simple problem to find the subsequence of length K with the largest sum

Detailed explanation of TCP (2)

Getting Started with CefSharp - winform

Safety 20220712

Daily practice of LeetCode - 138. Copy a linked list with random pointers

Ambiguous method call.both

Detailed explanation of TCP (3)
随机推荐
Daily practice of LeetCode - palindrome structure of OR36 linked list
A brief introduction to the CheckBox component of the basic components of Flutter
浅识Flutter 基本组件之CheckBox组件
Point Cloud DBSCAN Clustering (MATLAB, not built-in function)
VS QT - ui does not display newly added members (controls) || code is silent
递归查询单表-单表树结构-(自用)
【HCIP】ISIS
CloudCompare&PCL 计算两个点云之间的重叠度
接口测试关键技术
数据库文件中的未分配的块和未使用的块的区别
2022 Nioke Multi-School League Game 4 Solution
els 方块向右移
Zotero如何删除自动生成的标签
[C language] Three-pointed chess (classic solution + list diagram)
type_traits元编程库学习
Detailed explanation of TCP and UDP
RESTful api接口设计规范
Based on the local, linking the world | Schneider Electric "Industrial SI Alliance" joins hands with partners to go to the future industry
SIP协议标准和实现机制
VS QT——ui不显示新添加成员(控件)||代码无提示