0

ユーザーのログイン詳細を取得してメインページにリダイレクトするログインページを作成したいと思います。どうすればいいのかわからない。plzは私を助けます。

 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

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)を使用してWebビューを作成し、現在のコントローラーにWebビューを追加して表示します。

于 2012-11-09T08:00:45.790 に答える
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

この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 に答える