1

在我的应用程序中,我使用 Uiwebview 来显示 vimeo 授权页面,在用户授权后,我必须解析 OAtoken 的 url 并关闭它,因为我正在使用应该 startLoad 委托方法,但是在进程结束之后以及何时我返回NO,控制权没有转移回来......

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

NSURL *url = [request mainDocumentURL];
NSString *str1 = [url absoluteString];
NSString *str = @"https://vimeo.com/oauth/confirmed";
//[webView setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"bg_cork.png"]]];
if([str isEqualToString:str1])
{
    //removing the webview after the user approves.
    //[webView removeFromSuperview];
    return YES;
}

//parsing the redirected url to get the oauth_verifier.
URLParser *parser = [[URLParser alloc] initWithURLString:str1];
Oauth_verifier = [parser valueForVariable:@"oauth_verifier"];

//getting the final access token by giving the oauth verifier.

NSURL *url_access = [[NSURL alloc] initWithString:@"https://vimeo.com/oauth/access_token"];
OAMutableURLRequest *reques_access = [[OAMutableURLRequest alloc]initWithURL:url_access consumer:consumer token:acessToken realm:nil signatureProvider:nil];

OARequestParameter *p2 = [[OARequestParameter alloc] initWithName:@"oauth_verifier" value:Oauth_verifier];
NSArray *params2 = [NSArray arrayWithObject:p2];
[reques_access setParameters:params2];

[reques_access setHTTPMethod:@"GET"];
OADataFetcher *fetcher_access = [[OADataFetcher alloc]init];
[fetcher_access fetchDataWithRequest:reques_access delegate:self didFinishSelector:@selector(acessTokenTicket:didFinishWithData:) didFailSelector:@selector(acessTokenTicket:didFailWithError:)];

//if the access token is successfully generated then the control transferrd to  acessTokenTicket did finish with data

// Return YES if you want to load the page, and NO if you don't.

NSLog(@"at return yes");
if (i==1) {
    NSLog(@"returning no");
    [webView removeFromSuperview];
    return NO;
}
return YES;

}

我确信它会返回 no,因为打印了“returning no”语句,但没有返回控件,我已经给出了语句 NSLog(@"returned from web view delegate"); 在 main 函数中知道控件是否被返回,它没有返回,也没有执行下面的操作。

4

0 回答 0