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

查看:25
本文介绍了如何防止 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.

但是,现在我的问题是,谷歌在哪里说 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

在这种情况下 interactive 意味着您不能像通常在主应用程序中使用视图那样触摸/拖动/交互 Widget 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?).

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