0

我想创建一个登录页面,该页面将获取用户的登录详细信息并将他重定向到主页。我不知道我该怎么做。请帮助我。

 if([username isEqualToString:@"aa"] && [password isEqualToString:@"aa"])
    {
        Supportingwv *swv = [[Supportingwv alloc]initWithNibName:@"supportingwv"bundle:nil];
        NSString *urlstring = @"www.google.com";
        [ swv setUrlString : urlstring];
        [self.view addSubview:swv.view];
    }
    else
    {        
        UIAlertView * alert = [[UIAlertView alloc]initWithTitle:@"invalid authentication" message:@"username & password doesnot match" delegate:nil cancelButtonTitle:@"ok" otherButtonTitles:nil, nil];
        [alert show];
        [alert show];
    }
4

3 回答 3

0

你现在应该检查这个 webview 的代表

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

NSString *urlString = request.URL.absoluteString;
//Check the username or password in urlString with the help of RegularExpression


//or check user has succssfully login or not
   }
于 2012-11-09T11:07:26.457 回答
0

尝试这个

 NSString *urlAddress = @"http://www.google.com";
    NSURL *url = [NSURL URLWithString:urlAddress];
    NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
    [swv loadRequest:requestObj];
    [self.view addSubview:swv.view]; 
    [swv release];
于 2012-11-09T09:14:45.247 回答
0

我猜 Supportingwv 是一个 UIWebView,所以你必须加载请求loadRequest 方法

[swv loadRequest:[NSURLRequest requestWithURL:[NSURL urlWithString:urlString]]];

但如果没有更多解释,我们将无法帮助您。

编辑 :

如果要加载页面,只需使用以下内容:

if([username isEqualToString:@"aa"] && [password isEqualToString:@"aa"])
{
    UIWebView *webView = [[UIWebView alloc] initWithFrame:self.view.frame];
    [webView loadRequest:[NSURLRequest requestWithURL:[URL urlWithString:@"www.google.com"]]];
    [self.view addSubview:webView];
}
else
{        
    UIAlertView * alert = [[UIAlertView alloc]initWithTitle:@"invalid authentication" message:@"username & password doesnot match" delegate:nil cancelButtonTitle:@"ok" otherButtonTitles:nil, nil];
    [alert show];
}

此代码使用您想要的 URL(这里是 www.google.com)创建一个 webview,并将 webview 添加并显示到当前控制器。

于 2012-11-09T08:00:45.790 回答