Dashcode 中未定义 Widget 对象

发布于 2024-11-05 21:04:34 字数 644 浏览 3 评论 0原文

我正在将 Dashcode 用于移动 Safari Web 应用程序并来自文档 (https://developer.apple.com/library/archive/documentation/AppleApplications/Conceptual/Dashcode_UserGuide/Contents/Resources/en.lproj/MakingaWidgetwithDashcode/MakingaWidgetwithDashcode.html),看来我应该能够访问一个名为“widget”的对象。

但是,当我尝试时,我收到错误消息,指出小部件未定义。我也尝试过“window.widget”,它给了我同样的错误。

这是怎么回事?

我想在我的应用程序中创建一个可点击的链接,以使用 openURL 打开 URL(如上面 URL 中给出的示例)。

I'm using Dashcode for a mobile Safari web application and from the documentation (https://developer.apple.com/library/archive/documentation/AppleApplications/Conceptual/Dashcode_UserGuide/Contents/Resources/en.lproj/MakingaWidgetwithDashcode/MakingaWidgetwithDashcode.html), it appears that I should be able to access an object called "widget".

However, when I tried, I get the error message saying that widget is undefined. I've also tried "window.widget" and it gives me the same error.

What's going on?

I'd like to make a text in my application a clickable link to open a URL using openURL (like the example given at the URL above).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

浅听莫相离 2024-11-12 21:04:35

您可以使用 widget.xxx 来访问小部件内部和外部的内容。
因此,要访问curl和Mac并从雅虎获取一些数据,您需要执行以下操作

var yahoorate = widget.system("/usr/bin/curl 'http://download.finance.yahoo.com/d/quotes.csv?s=EUR" + interim0 + "=X&f=l1'", null).outputString;

来获取首选项键值,当您安装在Mac上时,该值存储在小部件plist中

globalPreferenceValue = widget.preferenceForKey(null, "your-key");

我认为在问题中(下面)我们正在检查是否我们在一个小部件中,然后准备过渡到小部件的后面。

if (window.widget) {
    widget.prepareForTransition("ToBack");
}

这就是我设置首选项的方式,以便它在系统重新启动之间存储(您使用获取首选项来检索它们)

widget.setPreferenceForKey(2,"ratePrecision");

,这就是您创建链接以在浏览器而不是小部件中打开的方式

<a onclick=" + "widget.openURL('http://www.wf.com/private/?ID=636');" + "><span id=company-info>click here</span></a>

这些都是我拥有的小部件中的相关工作示例建造的。希望有帮助。我发现下载与我想要的功能类似的小部件非常有用,然后安装它们并将它们作为项目打开,您可以导入,然后您可以看到所有代码。

You use widget.xxx to access things inside and outside you widget.
So to access curl and the Mac and get some data from Yahoo you do as follows

var yahoorate = widget.system("/usr/bin/curl 'http://download.finance.yahoo.com/d/quotes.csv?s=EUR" + interim0 + "=X&f=l1'", null).outputString;

to get a preference key value, stored in the widgets plist when you install on a mac

globalPreferenceValue = widget.preferenceForKey(null, "your-key");

i think in the question ask (below) we are checking to see if we are in a widget and then preparing a transition to the back of the widget.

if (window.widget) {
    widget.prepareForTransition("ToBack");
}

this is how i set a preference so it is stored between system reboots (you use a get preference to retrieve them)

widget.setPreferenceForKey(2,"ratePrecision");

and this is how you create a link to open in a browser not the widget

<a onclick=" + "widget.openURL('http://www.wf.com/private/?ID=636');" + "><span id=company-info>click here</span></a>

These are all rel working examples from widgets i have built. Hope it helps. I found it useful to download widgets that performed similar functions to ones i wanted and then as well as installing them opening them as projects, you can import, and then you can see all the code.

定格我的天空 2024-11-12 21:04:35

好的,这有效...希望对其他人有帮助...

window.location = "http://www.apple.com";

Ok, this worked...hope it will help someone else...

window.location = "http://www.apple.com";
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文