当前位置:网站首页>[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")
}
}
}
边栏推荐
- 立足本土,链接全球 | 施耐德电气“工业SI同盟”携手伙伴共赴未来工业
- els 方块向右移
- TCP详解(三)
- 递归查询单表-单表树结构-(自用)
- Getting Started with CefSharp - winform
- 原子操作 CAS
- 【异常】The field file exceeds its maximum permitted size of 1048576 bytes.
- 安全20220709
- BP神经网络
- [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
猜你喜欢
web容器及IIS --- 中间件渗透方法1
Unity2D 自定义Scriptable Tiles的理解与使用(四)——开始着手构建一个基于Tile类的自定义tile(下)
【编译原理】递归下降语法分析设计原理与实现
Just debuted "Fight to Fame", safety and comfort are not lost
With 7 years of experience, how can functional test engineers improve their abilities step by step?
Know the showTimePicker method of the basic components of Flutter
MultipartFile文件上传
[C language] Preprocessing operation
Web container and IIS --- Middleware penetration method 1
[Compilation principle] Design principle and implementation of recursive descent parsing
随机推荐
els 方块向左移动条件判断
【Exception】The field file exceeds its maximum permitted size of 1048576 bytes.
【AUTOSAR-RTE】-4-Port和Interface以及Data Type
【论文阅读】Mastering the game of Go with deep neural networks and tree search
安全20220712
[C language] General method of expression evaluation
IDEA 注释报红解决
Daily practice of LeetCode - 138. Copy a linked list with random pointers
some of my own thoughts
解析小结—自用
Why SocialFi achievement Web3 decentralized social in the future
Analysis summary - self-use
「 每日一练,快乐水题 」1331. 数组序号转换
Day32 LeetCode
No qualifying bean of type 问题
浅识Flutter 基本组件之CheckboxListTile组件
自己的一些思考
端口排查步骤-7680端口分析-Dosvc服务
LeetCode每日一练 —— OR36 链表的回文结构
Key Technologies of Interface Testing