小编use*_*747的帖子

永远不会调用shouldStartLoadWithRequest

我已经研究过并且仍然不明白为什么从未调用过StartLoadWithRequest.我的页面加载正常,并调用了一些UIWebview委托协议方法.请从以下代码中找到相关的摘要:

在我的.m中合成我的webview(在头文件中定义):

@implementation PortViewController

@synthesize WebView = myWebView;
Run Code Online (Sandbox Code Playgroud)

我成功加载了我的webview:

    myURLString = [NSString stringWithFormat:@"https://%@", defaultWebsite];

    myURL = [NSURL URLWithString: myURLString];
    NSURLRequest *myRequest = [NSURLRequest requestWithURL:myURL];
    [myWebView loadRequest:myRequest];
Run Code Online (Sandbox Code Playgroud)

把我的代表设置为自我

- (void)viewDidLoad
{


[super viewDidLoad];
[myWebView setOpaque:NO];
[myWebView setBackgroundColor:[UIColor clearColor]];

//myWebView.description.

myWebView.delegate = self;
}
Run Code Online (Sandbox Code Playgroud)

我的所有协议方法都被称为EXCEPT shouldStartLoadWithRequest

- (void)webViewDidStartLoad:(UIWebView *)myWebView {
    [activityIndicator startAnimating];
}

- (void)webViewDidFinishLoad:(UIWebView *)myWebView {
    [activityIndicator stopAnimating];
}

- (BOOL)WebView:(UIWebView *)myWebView shouldStartLoadWithRequest:(NSURLRequest *)request          navigationType:(UIWebViewNavigationType)navigationType {

NSLog(@"inside Webview");
if([[request.URL absoluteString] hasPrefix:@"http://www.nzx"]) {
    // do stuff
    NSLog(@"Have caught the prefix");
    return YES; …
Run Code Online (Sandbox Code Playgroud)

methods protocols ios uiwebviewdelegate

7
推荐指数
2
解决办法
2万
查看次数

标签 统计

ios ×1

methods ×1

protocols ×1

uiwebviewdelegate ×1