当前位置:网站首页>[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("进入消息")
}
}
}
边栏推荐
- Redis 使用LIST做最新评论缓存
- Mysql 45 study notes (23) How does MYSQL ensure that data is not lost
- 日志级别 和 打印log注意
- CloudCompare & PCL calculate the degree of overlap between two point clouds
- 想从手工测试转岗自动化测试,需要学习哪些技能?
- 原子操作 CAS
- False positives and false negatives in testing are equally worthy of repeated corrections
- Mysql 45讲学习笔记(二十五)MYSQL保证高可用
- 立足本土,链接全球 | 施耐德电气“工业SI同盟”携手伙伴共赴未来工业
- 接口测试关键技术
猜你喜欢
5. SAP ABAP OData 服务如何支持 $filter (过滤)操作
[Dynamic programming] Maximum sum of consecutive subarrays
endian mode
With 7 years of experience, how can functional test engineers improve their abilities step by step?
What skills do I need to learn to move from manual testing to automated testing?
The application and practice of mid-to-platform brand advertising platform
What is a distributed lock?Three ways of implementing distributed lock
A brief introduction to the showDatePicker method of the basic components of Flutter
【C语言】预处理操作
Web container and IIS --- Middleware penetration method 1
随机推荐
遗留系统的自动化策略
C# remote debugging
LeetCode简单题之两个数组间的距离值
接口测试关键技术
False positives and false negatives in testing are equally worthy of repeated corrections
Zotero如何删除自动生成的标签
[C language] General method for finding the sum of the greatest common factor and the least common multiple of two integers m and n, the classical solution
els block to the right
Office automation case: how to automatically generate period data?
TCP详解(二)
Is interprofessional examination difficult?Low success rate of "going ashore"?Please accept this practical guide!
7年经验,功能测试工程师该如何一步步提升自己的能力呢?
安全20220722
Mysql 45讲学习笔记(二十三)MYSQL怎么保证数据不丢
端口排查步骤-7680端口分析-Dosvc服务
VS QT——ui不显示新添加成员(控件)||代码无提示
大小端模式
顺序表的实现
Why SocialFi achievement Web3 decentralized social in the future
【Exception】The field file exceeds its maximum permitted size of 1048576 bytes.