【问题标题】:iOS xcode Alternative to UIWebview didFinishLoadiOS xcode 替代 UIWebview didFinishLoad
【发布时间】:2014-12-27 12:39:47
【问题描述】:

我有一个 webview 加载时,用户通过 POST 请求登录。他们登录后,我希望他们被带到一个网页。我的 POST 请求是一个如下 URL:

- (void)viewDidLoad {
[super viewDidLoad];
[_scoreWebView setDelegate:self];

NSMutableURLRequest *detailRequest = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"myrul"]];

[detailRequest setHTTPMethod:@"POST"];

NSString *sendInfo =[NSString stringWithFormat:@"action=login&EMAIL=email&PASSWORD=password", nil];

NSData *infoData = [sendInfo dataUsingEncoding:NSUTF8StringEncoding];

[detailRequest setHTTPBody:infoData];

[_scoreWebView loadRequest:detailRequest];
}

此登录过程运行良好。但是,在我将用户发送到我的网页后,它会无限启动 webviewdidfinishload。我知道每次加载某些东西时它都会触发。登录后是否有替代解决方案将用户重定向到我的页面?此外,我有三个不同的页面,用户可以根据他们的输入被重定向到,这只是其中之一,为简单起见。这是我的完成加载方法:

- (void)webViewDidFinishLoad:(UIWebView *)webView
{
     //Check here if still webview is loding the content
if (webView.isLoading)
    return;
else //finished
    NSLog(@"finished loading");

NSLog(@"%@ in calendar", _thisScriptUniqueID);

NSString *fullURL=[NSString stringWithFormat:@"myurl/%@#score", _thisScriptUniqueID];

NSLog(@"%@", fullURL);


NSURL *url = [NSURL URLWithString:fullURL];

NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];

[_scoreWebView loadRequest:requestObj];
}

是否可以使用不同的方法将用户带到页面,或者是否可以将两者都包含在 viewDidLoad 中?

【问题讨论】:

    标签: ios objective-c xcode uiwebview


    【解决方案1】:

    经过大量研究,我认为该功能在服务器端会更好地工作。我这样做是为了让相同的 URL 登录用户并同时将他们带到所需的页面。

    【讨论】:

      猜你喜欢
      • 2013-04-04
      • 1970-01-01
      • 2012-12-01
      • 2016-10-07
      • 2011-03-19
      • 2011-05-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多