当前位置:网站首页>[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")
}
}
}
边栏推荐
猜你喜欢

The application and practice of mid-to-platform brand advertising platform

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

A brief introduction to the CheckboxListTile component of the basic components of Flutter

IIR滤波器和FIR滤波器

大小端模式

【异常】The field file exceeds its maximum permitted size of 1048576 bytes.

C# remote debugging

MP使用时的几个常见报错

How to develop a high-quality test case?

No qualifying bean of type 问题
随机推荐
【Cocos Creator 3.5】缓动系统停止所有动画
Pytest电商项目实战(上)
QML的使用
安全20220709
点云DBSCAN聚类(MATLAB,非内置函数)
No qualifying bean of type 问题
Daily practice of LeetCode - 138. Copy a linked list with random pointers
LocalDate加减操作及比较大小
LeetCode简单题之两个数组间的距离值
一份高质量的测试用例如何养成?
What is SQALE
[C language] General method of expression evaluation
组件传值 provide/inject
els block to the right
安全20220712
数据库实现分布式锁
3.5 】 【 Cocos Creator slow operating system to stop all animations
[Swift]自定义点击APP图标弹出的快捷方式
BP神经网络
接口测试关键技术