没有触发self.viewcontroller.webview.delegate = self + PhoneGap + secondtime

时间:2012-04-07 14:01:57

标签: iphone

我必须第二次重新加载mainviewcontroller webview并重新加载webview。

APPDELGATE:

- (void) webViewDidFinishLoad:(UIWebView*) theWebView 
{


    // only valid if FooBar.plist specifies a protocol to handle
    if (self.invokeString)
    {
        // this is passed before the deviceready event is fired, so you can access it in js when you receive deviceready
        NSString* jsString = [NSString stringWithFormat:@"var invokeString = \"%@\";", self.invokeString];
        [theWebView stringByEvaluatingJavaScriptFromString:jsString];

    }else {



         if([loginComplete isEqualToString:@"1"] ){


            NSString *page = @"intro.html";
            NSString* jsString = [NSString stringWithFormat:@"loadParams('%@','%@','%@');", at,userfbid,page];
            [theWebView stringByEvaluatingJavaScriptFromString:jsString];

        }

        else {
            NSString *page = @"friends.html";
            NSString* jsString = [NSString stringWithFormat:@"loadParams('%@','%@','%@');", at,userfbid,page];
            [theWebView stringByEvaluatingJavaScriptFromString:jsString];
        }


        // Black base color for background matches the native apps
        theWebView.backgroundColor = [UIColor grayColor];

        return [self.viewController webViewDidFinishLoad:theWebView];
    }




 -(void)insert{

        self.viewcontroller.webview.delegate=self;

        }

Webdelegate未在插入中触发。

由于

1 个答案:

答案 0 :(得分:0)

试试这个:

return [self webViewDidFinishLoad:theWebView];

而不是:

return [self.viewController webViewDidFinishLoad:theWebView];

因为您的AppDelegate是webView的webViewDidFinishLoaded的委托,而不是webView本身。