0

I have a UIWebView that opens up a webpage in my app where a user can log in to their account. What I want the app to do is to change view controllers immediately after the user has logged into their account without seeing the next webpage in the webview. This is the code in my viewDidLoad function:

- (void)viewDidLoad {
    [super viewDidLoad];
    NSString *webpage = @"myfakewebpage.com";
    self.defaults = [NSUserDefaults standardUserDefaults];

    [self.activityIndicator startAnimating];
    [self.myWebView setHidden:YES];

    self.myWebView.delegate = self;

    NSURL *myURL = [NSURL URLWithString:triggerPage];
    self.myRequest = [NSURLRequest requestWithURL:myURL];
    [self.myWebView loadRequest:self.myRequest];
}

And this is what my webViewDidFinishLoad function looks like:

- (void)webViewDidFinishLoad:(UIWebView *)webView {
    if ([self.activityIndicator isAnimating] == YES) {
        [self.activityIndicator stopAnimating];
        [self.activityIndicator setHidden:YES];
        [self.myWebView setHidden:NO];
    }
    [self loadViewControllerAfterAuthentication];
}

[self loadViewControllerAfterAuthentication]; calls a function I built myself that will change the view controller through a poor workaround based on the response of the webpage after the user has authenticated. As of right now, the user can authenticate, but the next webpage will load for about half a second before my code kicks in and a new view controller is displayed. If anyone has an idea on how I can make the transition described above any smoother, that would be greatly appreciated.

johnmm
  • 21
  • 8
  • What are you trying to do? Why is the webView hidden? – Mika Apr 14 '15 at 19:20
  • What I need to do is leave the webView and load a new viewController after the user has logged into their account on the webpage in the webView. BUT, the only webpage that I want to see is the login page. After the user has successfully entered the correct credentials, that's when I want to leave the webView and load the new View Controller. The webView is hidden until the webpage can be loaded. Until the webpage is finished loading, there will be an activity indicator up on the screen showing that the webpage is being loaded. – johnmm Apr 14 '15 at 19:28
  • yea but what happens when the user enters the wrong credentials? – Mika Apr 14 '15 at 20:29
  • If the user enters the wrong credentials, nothing should happen. As in the webView stays and no new view controller get loaded. Also, the webpage in the webView should remain at the log in screen until the user enters the correct credentials. – johnmm Apr 16 '15 at 12:42

0 Answers0