I have created a TabBarController application that currently has two tabs. Each tab contains a WebView. of course each webview opens a certain web page. The site that the webviews connect to require the use to be logged in.
To take care of the login, I have created a LoginViewController. I use presentModalViewController from the appDelegate to open the login screen.
Code:
LoginViewController *lvc = [[LoginViewController alloc] initWithNibName:@"LoginViewController" bundle:nil];
lvc.delegate = self;
[self.tabBarController presentModalViewController:lvc animated:NO];
[lvc release];
I then use an HTTP POST to check the login information and use the response from the webpage to see if the login credentials are valid. Once the credentials have been validated, I remove the LoginView using dismissModalViewControllerAnimated.
Code:
- (void)loginViewControllerDidFinish:(LoginViewController *)loginViewController
{
[self.tabBarController dismissModalViewControllerAnimated:YES];
}
The problem I am having is that my TabBarController is loaded when the app is loaded and therefore the webview content is loaded when the app is loaded. This happens before the login credentials have been submitted and therefore the web pages that are being loaded into the WebViews are redirected back to the login page of the web site.
So, my questions are:
- What is the best way to handle this situation? Should I not be loading the TabBar controller at app launch and displaying the login page as a modal view?
- Is there a way to tell the WebView to load a certain URL from the tabBarController didSelectViewController method?
- What method should I use to load the URL in the WebView? awakeFromNib, viewDidLoad, viewWillAppear, etc.?
I am open to all ideas. I am pretty new to iPhone development. I have read everything I could find on this topic and searched the internet. This issue has had me stuck all day now.
Please help.
Keith