-1

我已经从这里成功安装了 iOS 的日历插件(我认为): https ://github.com/phonegap/phonegap-plugins/tree/master/iOS/CalendarPlugin

但是我似乎无法让它工作。到目前为止,这是我所做的:

  1. 将日历 .h 和 .m 文件放入我项目的插件文件夹中。
  2. 将 calendar.js 文件添加到我的目录结构中并在标题中链接
  3. 在我的项目中添加了 EventKit 和 EventKitUI 框架
  4. 将术语 calendarPlugin 添加到我的 cordova.plist 文件中

5.将以下代码添加到我要保存的第一页:

window.plugins.calendarPlugin.prototype.createEvent = function(title,location,notes, startDate, endDate){
                var title= "My Appt";
                var location = "Los Felix";
                var notes = "me testing";
                var startDate = "2012-11-23 09:30:00";
                var endDate = "2012-11-23 12:30:00";



   cal.createEvent(title,location,notes,startDate,endDate);
            }

            $(document).ready(function() {
                    cal = window.plugins.calendarPlugin;
                    var cal;

 $('.calinfo').live('click', function() {

          var desiredValue = $(this).parent().prev().find('.calendar').val();
                                             console.log(desiredValue);                                               
                                             var calInfo = desiredValue.split(',');

             createEvent(calInfo[0], calInfo[1], calInfo[2], calInfo[3], calInfo[4]);

                                            });                              
                    });

当我运行它时,注意到发生了。我错过了什么吗?

4

1 回答 1

0

不要使用 $(document).ready(function());。而是使用准备好的设备。在身体负荷上调用函数 onBodyLoad()。

    function onBodyLoad()
        {        
            document.addEventListener("deviceready", onDeviceReady, false);
            deviceready = true;
        }

//////////////////////////////

    function onDeviceReady()
    {
       // Your code goes here

    }
于 2012-08-09T08:01:52.903 回答