问题描述
我正在尝试安装位于以下位置的PhoneGap插件: https: //github.com/phonegap/phonegap-plugins/tree/master/iPhone/MessageBox .但是,我无法使其正常运行.
I'm trying to install a PhoneGap plugin located here: https://github.com/phonegap/phonegap-plugins/tree/master/iPhone/MessageBox. However, I am unable to get it working.
这是我尝试过的步骤:
- 确保已为iOS 4更新了PhoneGap Xcode项目SDK
- 将MessageBox文件夹从Finder拖放到您的插件中
XCode中的文件夹,使用为任何添加的文件夹创建组" - 将.js文件添加到磁盘上的www文件夹,并添加引用到.js文件中作为HTML文件中的标签
- 使用键MessageBox和值MessageBox将新条目添加到插件中PhoneGap.plist
- Make sure your PhoneGap Xcode project has been updated for the iOS 4SDK
- Drag and drop the MessageBox folder from Finder to your Plugins
folder in XCode, using "Create groups for any added folders" - Add the .js files to your www folder on disk, and add reference(s)to the .js files as tags in your html file(s)
- Add new entry with key MessageBox and value MessageBox to Plugins inPhoneGap.plist
在我的HTML页面上,我有:
On my HTML page, I have:
<script type="text/javascript">
var messageBox = window.plugins.messageBox;
messageBox.alert('Title', 'Message', function(button) { console.warn('alert', [this, arguments]); });
</script>
(请注意,所需的.js文件已包含在页面的前面)
(note that the required .js file is included earlier in the page)
但是,当我运行项目时,很遗憾,我没有看到任何消息框.只是我的HTML页面.
我将不胜感激,谢谢!
When I run the project, though, I unfortunately do not see any message boxes. Just my HTML page.
I'd appreciate any help, thanks!
我在上面显示的Javascript代码中可能存在错误?
Maybe there is an error in that Javascript code I've shown above?
推荐答案
您是否正在等待设备准备好在phonegap中被调用?如果不是,那么您应该这样做,以便在调用消息框之前,插件和所有必要的部件有时间进行初始化
Are you waiting for the deviceready to be called in phonegap? if not then you should do that in order that the plugins and all necessary pieces have time to initialize before you call the message box
这篇关于无法安装PhoneGap插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!