当前位置:网站首页>[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("进入消息")
}
}
}
边栏推荐
- A brief introduction to the CheckboxListTile component of the basic components of Flutter
- Day32 LeetCode
- Use of QML
- [Dynamic programming] Maximum sum of consecutive subarrays
- Detailed explanation of TCP (2)
- 【Exception】The field file exceeds its maximum permitted size of 1048576 bytes.
- 安全20220715
- 【Cocos Creator 3.5】缓动系统停止所有动画
- 10 Permission introduction
- Select the smoke test case, and make the first pass for the product package entering QA
猜你喜欢

Mysql 45 study notes (23) How does MYSQL ensure that data is not lost

Web container and IIS --- Middleware penetration method 1

Database implements distributed locks

No qualifying bean of type 问题

C# remote debugging

Mysql 45讲学习笔记(二十五)MYSQL保证高可用

立足本土,链接全球 | 施耐德电气“工业SI同盟”携手伙伴共赴未来工业

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

数据库实现分布式锁

LeetCode简单题之找到和最大的长度为 K 的子序列
随机推荐
「 每日一练,快乐水题 」1331. 数组序号转换
PMP WeChat group daily exercises
addressable in Golang
【编译原理】递归下降语法分析设计原理与实现
The application and practice of mid-to-platform brand advertising platform
Observer pattern
【Cocos Creator 3.5】缓动系统停止所有动画
安全20220712
【Exception】The field file exceeds its maximum permitted size of 1048576 bytes.
浅识Flutter 基本组件之CheckboxListTile组件
Mysql 45 study notes (twenty-four) MYSQL master-slave consistency
A brief introduction to the CheckboxListTile component of the basic components of Flutter
7年经验,功能测试工程师该如何一步步提升自己的能力呢?
Why SocialFi achievement Web3 decentralized social in the future
【动态规划】连续子数组的最大和
Local area network computer hardware information collection tool
[C language] Three-pointed chess (classic solution + list diagram)
立足本土,链接全球 | 施耐德电气“工业SI同盟”携手伙伴共赴未来工业
Select the smoke test case, and make the first pass for the product package entering QA
MultipartFile文件上传