简体   繁体   English

iOS QuickAction的Objective-C代码

[英]Objective-C code for iOS QuickAction

I've an iOS app with a Tab Bar Controller and five ViewControllers written in Objective-C. 我有一个带有Tab栏控制器和五个用Objective-C编写的ViewController的iOS应用。 Now, I declared QuickActions in Info.plist file. 现在,我在Info.plist文件中声明了QuickActions。

But cause I'm new at coding and there are only Swift codes to find in the internet I don't know how to do it. 但是因为我是编码新手,所以在互联网上只能找到Swift代码,但我不知道该怎么做。

Can anyone provide the code snippet for AppDelegate.m in Objective-C to open an specific ViewController? 谁能在Objective-C中提供AppDelegate.m的代码片段以打开特定的ViewController?

Thank you for help! 谢谢你的帮助!

Greetings, David. 问候,大卫。

if your application is launched fresh...then its launchOptions will contain shortcut item pressed which you can access using key UIApplicationLaunchOptionsShortcutItemKey .Find the type UIApplicationShortcutItem to perform action accordingly. 如果您的应用程序是全新启动的...则其launchOptions将包含按下的快捷方式项目,您可以使用UIApplicationLaunchOptionsShortcutItemKey键访问该快捷方式项目。找到UIApplicationShortcutItem类型以相应地执行操作。

If your application is in background and your user selected shortcut item 如果您的应用程序在后台并且用户选择了快捷方式项

- (void)application:(UIApplication *)application performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem completionHandler:(void(^)(BOOL succeeded))completionHandler

will be called.As you can see you get pressed shortcut item directly you can get type of pressed item and perform action accordingly.Hope it helps :) 如您所见,您将直接获得被按下的快捷方式项,您可以获取被按下项的类型并相应地执行操作。希望它会有所帮助:)

Edit You can check out https://github.com/dakeshi/3D_Touch_HomeQuickAction this will help you alot only difference is he has used dynamic quick actions.And one note about quick actions (both dynamic and static) is that unless you launch your app at least once quick options won't show up on 3D touch. 编辑您可以查看https://github.com/dakeshi/3D_Touch_HomeQuickAction,这将帮助您很多不同,唯一不同的是他使用了动态快速动作。关于快速动作(动态和静态)的一个注意事项是,除非您启动应用程序至少一次,快速选项不会显示在3D触摸屏上。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM