当前位置:网站首页>[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")
}
}
}
边栏推荐
- Unity2D 自定义Scriptable Tiles的理解与使用(四)——开始着手构建一个基于Tile类的自定义tile(下)
- Detailed explanation of TCP (3)
- MultipartFile file upload
- LeetCode每日一练 —— 138. 复制带随机指针的链表
- Database implements distributed locks
- $attrs/$listeners
- 选好冒烟测试用例,为进入QA的制品包把好第一道关
- 下载jar包的好地方
- LeetCode简单题之找到和最大的长度为 K 的子序列
- Recursive query single table - single table tree structure - (self-use)
猜你喜欢

type_traits元编程库学习

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

Unity2D 自定义Scriptable Tiles的理解与使用(四)——开始着手构建一个基于Tile类的自定义tile(下)

Redis实现分布式锁

Addition and Subtraction of Scores in LeetCode Medium Questions

TCP详解(一)

QML的使用

接口测试关键技术
![[C language] General method of expression evaluation](/img/59/cf43b7dd16c203b4f31c1591615955.jpg)
[C language] General method of expression evaluation

Mysql 45 study notes (twenty-five) MYSQL guarantees high availability
随机推荐
Web container and IIS --- Middleware penetration method 1
【动态规划】连续子数组的最大和
安全20220709
TCP详解(三)
【C语言】预处理操作
顺序表的实现
Detailed explanation of TCP (1)
Select the smoke test case, and make the first pass for the product package entering QA
LeetCode简单题之两个数组间的距离值
[C language] General method of expression evaluation
LocalDate加减操作及比较大小
[Godot][GDScript] 二维洞穴地图随机生成
C primer plus study notes - 8, structure
Key Technologies of Interface Testing
Recursive query single table - single table tree structure - (self-use)
SQL Interview Questions (Key Points)
SIP协议标准和实现机制
Ambiguous method call.both
Problems that need to be solved in distributed system architecture
[C language] Preprocessing operation