我已经解决了所有其他问题,但我无法弄清楚出了什么问题。我从 Apple Developer 网站Add Home Screen Quick Actions下载了示例项目,这没问题,但是当我开始一个新的 Xcode 项目并复制它时,它对我不起作用。我肯定错过了什么。在这一点上,我只希望它在控制台中打印出“按下快捷方式”。当我添加print("Shortcut pressed")到我下载的 Apple 项目时,它工作正常。
在这一点上,我只是在尝试随机的事情。
我用一个数组、一个字典和字符串更新了我的 info.plist,我只是复制并传递了这些值,以免出现任何拼写错误。
UIApplicationShortcutItems, Item 0, UIApplicationShortcutItemType, UIApplicationShortcutItemIconType, UIApplicationShortcutItemTitle
按应用程序图标时会出现快捷方式,但它只是打开应用程序。
这是我非常基本的 AppDelegate.Swift 文件,只是想让它做任何事情 难道是我的项目设置,我的 Xcode 版本是最新的 - 版本 11.1 (11A1027)
我以前从未使用过快速操作,它看起来很简单,但实际上很简单,只需在 plist 中添加一些行并将一些代码添加到 AppDelegate.Swift 文件中,但需要很长时间才能开始工作。
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var shortcutItemToProcess: UIApplicationShortcutItem?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
if let shortcutItem = launchOptions?[UIApplication.LaunchOptionsKey.shortcutItem] as? UIApplicationShortcutItem { …Run Code Online (Sandbox Code Playgroud) 我是 Swift 的新手,一直在使用 SwiftUI,而不是 Storyboard。
我在 Info.plist 中设置了 UIApplicationShortcutItems,并有两个快速操作可以使用 launchOptions 显示警报。
我能够在 SceneDelegate.swift 中切换快速操作
func windowScene(_ windowScene: UIWindowScene, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: @escaping (Bool) -> Void) {
switch shortcutItem.type {
case "QuickAction1":
OneView() // What do I do to open this SwiftUI struct View?
break
case "QuickAction2":
SecondView() // What do I do to open this SwiftUI struct View?
break
default:
break
}
}
Run Code Online (Sandbox Code Playgroud)
使用 SwiftUI 从家庭快速操作打开特定视图的正确方法是什么?
内容视图.swift
struct ContentView: View {
var body: some View {
NavigationView {
VStack …Run Code Online (Sandbox Code Playgroud) 我需要创建某种类型的快速操作菜单,只要用户单击该按钮,该菜单就会显示在单击项目(按钮)的右侧.
这是我想要实现的一个例子:

当用户点击button1时,我希望"子快速操作菜单"显示为如上图所示.反正有没有在Android中'本地'这样做?
我找到了这个插件但它只允许你从按钮的顶部或底部显示菜单. https://github.com/lorensiuswlt/NewQuickAction3D
正如我在照片中提到的,我不知道这个小部件是什么?以及如何创建它并在我们的项目中使用它?

我最近添加的 quick_actions 插件在调试模式下工作正常,但在发布模式下显示空白屏幕。
在日志中发现了这些问题。
[ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: MissingPluginException(No implementation found for method getLaunchAction on channel plugins.flutter.io/quick_actions)
#0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:157)
<asynchronous suspension>
#1 QuickActions.initialize (package:quick_actions/quick_actions.dart:68)
[ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: MissingPluginException(No implementation found for method setShortcutItems on channel plugins.flutter.io/quick_actions)
#0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:157)
Run Code Online (Sandbox Code Playgroud)