मैं समारोह का उपयोग कर एक html पृष्ठ में एक जावास्क्रिप्ट कॉल करने के लिए कोशिश कर रहा हूँ का उपयोग कर जावास्क्रिप्ट कॉलिंग -UIWebView
<script>
function methodName()
{
// code to draw graph
}
हालांकि -
View did load function
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *writablePath = [documentsDirectory stringByAppendingPathComponent:@"BasicGraph.html"];
NSURL *urlStr = [NSURL fileURLWithPath:writablePath];
NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *myPathInfo = [[NSBundle mainBundle] pathForResource:@"BasicGraph" ofType:@"html"];
[fileManager copyItemAtPath:myPathInfo toPath:writablePath error:NULL];
[graphView loadRequest:[NSURLRequest requestWithURL:urlStr]];
}
- (void) webViewDidFinishLoad:(UIWebView *)webView
{
[graphView stringByEvaluatingJavaScriptFromString:@"methodName()"];
}
यहाँ एचटीएमएल पृष्ठ पर जावास्क्रिप्ट है , फ़ंक्शन methodName()
कॉल नहीं किया जा रहा है लेकिन window.onload = function() के बाद सब कुछ ठीक काम कर रहा है ..
मैं अपने आवेदन में RGraphs को एकीकृत करने की कोशिश कर रहा हूं और Basic.html
वह HTML पृष्ठ है जिसमें जावास्क्रिप्ट लिखे गए हैं।
यह अच्छा होगा अगर कोई इस से मेरी मदद कर सके।
अरे, अगर आपको कोई फर्क नहीं पड़ता है तो कृपया अपना नमूना कोड साझा कर सकते हैं जहां मैं देशी आईओएस कोड से rgrpahs को कॉल कर सकता हूं? यह बहुत उपयोगी होगा। पिछले एक हफ्ते से मैं इसे काम करने के लिए संघर्ष कर रहा हूं। – iamMobile
मैंने अभी UIWebview में जावास्क्रिप्ट चलाने के विषय पर एक सुरुचिपूर्ण डेमो बनाया है, कृपया देखें: http: //creiapp.blogspot.hk/2013/04/uiwebview-javascript.html –