views:

33

answers:

2

I have a view and a button. When the button is pushed, I present a modal view controller that has a uiwebview, and a navigation bar at the top. The hardcoded uiwebview shows a login prompt. Once the user goes in and enters the correct login credentials and hits GO on the keyboard, I not only need it to authenticate me into the server, but also dismiss the modal view controller.

Note the text field I enter data into is part of the website loaded in uiwebview...

When I hit enter now, the web page authenticates, and everything is peachy, but I just need a way to tie in a

[self dismissModalViewControllerAnimated:YES];

command when they hit GO...any thoughts?

Thanks

EDIT

Here is the code that I am implementing in the loginView:

- (void)viewDidLoad {
    [super viewDidLoad];
    NSURL *url = [[NSURL alloc] initWithString: @"http://website"];
    NSURLRequest *request = [[NSURLRequest alloc] initWithURL: url];
    [webView loadRequest: request];

    [request release];
    [url release];


}

-(BOOL) textFieldShouldReturn:(UITextField *)textField{


        [self dismissModalViewControllerAnimated:YES];

    return YES;
}

-(IBAction) done{

    [self dismissModalViewControllerAnimated:YES];
}
+1  A: 

First determine the URL the webpage takes you to on successful login, let's say it's

http://website/logedin
. Implement UIWebViewDelegate, and detect when a request is made to that address:

- (BOOL)webView:(UIWebView *)wv shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
  if ([[request.URL absoluteString] isEqualToString:@"http://website/logedin"]) {
    [self dismissModalViewControllerAnimated:YES];
    return NO;
  }
  return YES;
}
Aleph
A: 
jfalexvijay