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

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

问题描述

因此,我已经阅读了几篇博客、帖子和 Apple 自己的人机界面指南,其中指出 iOS 14 小部件不是交互式的,但是:按下目标时可以传递一个指向应用程序的短链接.Apple 自己说:Small Widgets 有一个单一的点击目标,Medium 和 Large Widgets 有多个点击目标".好的!

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/en-US/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

在这种情况下,交互式意味着您无法像通常在主应用程序中使用视图那样触摸/拖动小部件视图进行交互(请参阅为什么某些视图在小部件中显示为红色的禁止进入标志?).

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?).

此外,当您单击小部件时,您并没有真正与其视图进行交互 - 您只需打开应用程序.从 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天全站免登陆