我是iOS和Phonegap新手,請耐心等待。我在我的index.html下面的代碼 -Phonegap - 無法從javascript調用本機iOS功能
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的一個目標C類的方法打印有一個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
請添加您的MyClass.h文件代碼。你在擴展PGPlugin嗎? – rooftop 2012-02-29 23:08:38
@rooftop添加了它。我正在擴展PGPlugin。 – Suchi 2012-02-29 23:14:13