gpt4 book ai didi

iphone - Phonegap-无法从JavaScript调用本地iOS功能

转载 作者:行者123 更新时间:2023-12-01 19:22:33 25 4
gpt4 key购买 nike

我是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

最佳答案

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

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

关于iphone - Phonegap-无法从JavaScript调用本地iOS功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9507720/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com