从JS文件中调用Objective C中定义的方法。正在使用Phonegap框架。
MyClassViewController.h文件包含
-(int) returnTen;
MyClassViewController.m文件包含
-(int) returnTen
{
return 10;
}
<html>
<head>
<title>Sample</title>
<script type="text/javascript" src="phonegap.js"></script>
<script type="text/javascript">
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
var num = //Invoke "returnTen" so that 10 is stored in num variable
pText.innerHTML = num;
}
</script>
</head>
</html>