如何防止iOS 14 Widget打开应用并对回调做出反应 [英] How to prevent iOS 14 Widget opening app and react to callback

查看:86
本文介绍了如何防止iOS 14 Widget打开应用并对回调做出反应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我已经阅读了几篇博客,文章和Apple自己的人机接口指南,指出iOS 14小部件不是交互式的,但是:按下目标时,可以将短链接传递至该应用程序.苹果自己说:小控件有一个点击目标,中小控件有多个点击目标".好吧!

So, I already read several blogs, posts, and Apple's own Human Interface Guidelines that iOS 14 Widgets are NOT interactive, BUT: It's possible to pass a short link to the app when pressing on a target. Apple on its own says: "Small Widgets got one single tap target, Medium and Large Widgets got multiple tap targets". OK!

现在,当您点击这些目标时,应用程序将打开,并且小部件将短链接传递给应用程序.

Now when you tap on these Targets the app is opening and the Widget is passing that short link to the App.

但是,现在是我的问题,Google在哪里说Idk:

BUT, now my question, where Google says Idk:

在我在窗口小部件中创建的这些按钮之一上点击时,我可以以编程方式说防止打开应用程序"吗?就像使用Javascript一样简单:preventDefault()( https: //developer.mozilla.org/zh-CN/docs/Web/API/Event/preventDefault ).

Can I programmatically say "prevent opening app", when tapping on one of these buttons I've created in my Widget? It's just as easy as in Javascript: preventDefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault).

这可能吗?我只想防止打开应用程序,并访问触发的Tap-Target回调并在SwiftUI中处理我的东西.

Is this possible? I just want to prevent the opening of the app and access that Tap-Target Callback that is triggered and process my stuff in SwiftUI.

非常感谢,伙计们:)

推荐答案

在我在窗口小部件中创建的这些按钮之一上点击时,我可以以编程方式说防止打开应用程序"吗?

Can I programmatically say "prevent opening app", when tapping on one of these buttons I've created in my Widget?

不,这是不可能的(至少到目前为止,在iOS 14中).

No, this is simply not possible (at least so far, in iOS 14).

默认情况下,每当您点击窗口小部件时,都会打开该应用程序.您只能指定深层链接等,但它们将始终打开应用程序.

By default whenever you tap on a Widget, the App will be opened. You can only specify deep links etc. but they'll always open the app.

我已经读到[...] iOS 14小部件不是交互式的

I already read [...] that iOS 14 Widgets are NOT interactive

在这种情况下, interactive 表示您无法像通常在主应用程序中使用视图那样,与小部件 view 进行触摸/拖动/交互(参见为什么某些视图在小部件中显示为红色的无入口符号?).

In this context interactive means that you can't touch/drag/interact with a Widget view like you'd normally do with a view in your main app (see Why do some views appear as a red no entry sign in widgets?).

此外,当您单击Widget时,您并不会真正与其视图交互-只需打开该应用即可.从iOS 14开始,您无法更改它.

Also, when you click on a Widget, you don't really interact with its view - you just open the app. As of iOS 14 you can't change it.

这篇关于如何防止iOS 14 Widget打开应用并对回调做出反应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆