当前位置:网站首页>[Swift]自定义点击APP图标弹出的快捷方式
[Swift]自定义点击APP图标弹出的快捷方式
2022-07-31 03:21:00 【风浅月明】
开发中的APP,不做任何处理,点击弹出的快捷方式。
上线的APP,不做任何处理,点击弹出的快捷方式。
自定义快捷方式
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: "消息子标题", 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("进入消息")
}
}
}
边栏推荐
猜你喜欢
![[Compilation principle] Design principle and implementation of recursive descent parsing](/img/51/cd054a8246dc108520d6ff9ea26c60.png)
[Compilation principle] Design principle and implementation of recursive descent parsing

从滴滴罚款后数据治理思考

Key Technologies of Interface Testing

Database implements distributed locks

LeetCode每日一练 —— OR36 链表的回文结构

Redis implements distributed locks

LeetCode简单题之两个数组间的距离值

VS QT - ui does not display newly added members (controls) || code is silent

The distance value between two arrays of LeetCode simple questions

What is a distributed lock?Three ways of implementing distributed lock
随机推荐
【CocosCreator 3.5】CocosCreator 获取网络状态
Point Cloud DBSCAN Clustering (MATLAB, not built-in function)
【异常】The field file exceeds its maximum permitted size of 1048576 bytes.
【动态规划】连续子数组的最大和
分布式系统架构需要解决的问题
The Map Entry understanding and application
选好冒烟测试用例,为进入QA的制品包把好第一道关
【编译原理】递归下降语法分析设计原理与实现
Mysql 45 study notes (twenty-five) MYSQL guarantees high availability
【HCIP】ISIS
TCP详解(三)
Several common errors when using MP
[Dynamic programming] Maximum sum of consecutive subarrays
Difference between unallocated blocks and unused blocks in database files
beforeDestroy与destroyed的使用
【CocosCreator 3.5】CocosCreator get network status
12 Disk related commands
CloudCompare & PCL calculate the degree of overlap between two point clouds
SIP Protocol Standard and Implementation Mechanism
The distance value between two arrays of LeetCode simple questions