1

我是 iOS 和 Phonegap 的新手,所以请多多包涵。我的 index.html 中有以下代码 -

function onDeviceReady()
{
    // do your thing!
    //navigator.notification.alert("PhoneGap is working");
    MyClass.nativeFunction(
         ["HelloWorld"] ,
         function(result) {
                alert("Success : \r\n"+result);      
          },

          function(error) {
                 alert("Error : \r\n"+error);      
           }
     );  

}

我有另一个名为 MyClass.js 的文件,其中包含以下内容 -

var MyClass = {

nativeFunction: function(types, success, fail) {
return PhoneGap.exec(success, fail, "MyClass", "print", types);
}

}

我有一个名为 MyClass 的 Objective C 类,其方法 print 具有 NSLog 语句。但这永远达不到。这是什么原因?

更新:我的 .h 类

#import <Foundation/Foundation.h>
#import <PhoneGap/PGPlugin.h>

@interface MyClass : PGPlugin {

    NSString* callbackID;  
}

@property (nonatomic, copy) NSString* callbackID;

//Instance Method  
- (void) print:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options;

@end
4

1 回答 1

3

您是否已将插件添加到 PhoneGap.plist 文件中?

如果是这样,您使用了什么键/值?在我看来它应该是 MyClass/MyClass

于 2012-03-01T05:42:19.850 回答