Authored by 孙凯
Committed by 戴强

add 用cordova.version判断cordova是否注入成功 review by daiqiang

@@ -259,8 +259,18 @@ static float kprogressViewRadius = 2.0f; @@ -259,8 +259,18 @@ static float kprogressViewRadius = 2.0f;
259 - (BOOL)injectJavascript:(NSString *)resource { 259 - (BOOL)injectJavascript:(NSString *)resource {
260 NSString *jsPath = [[NSBundle mainBundle] pathForResource:resource ofType:@"js"]; 260 NSString *jsPath = [[NSBundle mainBundle] pathForResource:resource ofType:@"js"];
261 NSString *js = [NSString stringWithContentsOfFile:jsPath encoding:NSUTF8StringEncoding error:NULL]; 261 NSString *js = [NSString stringWithContentsOfFile:jsPath encoding:NSUTF8StringEncoding error:NULL];
  262 + [self.webView stringByEvaluatingJavaScriptFromString:js];
262 263
263 - return ([self.webView stringByEvaluatingJavaScriptFromString:js] != nil); 264 +
  265 + //用cordova.version判断cordova是否注入成功
  266 + NSString* jsCordovaVersion = [NSString stringWithFormat:
  267 + @"cordova.version"];
  268 + NSString* res = [self.webView stringByEvaluatingJavaScriptFromString:jsCordovaVersion];
  269 +
  270 + if (res != nil && res.length > 0) {
  271 + return TRUE;
  272 + }
  273 + return FALSE;
264 } 274 }
265 275
266 /** 276 /**