Saturday, July 10, 2010

Pushing UIWebView on Navigation controller

This is a stupid mistake that I did when I was a beginner:

Issue : When I am trying to push A UIWebView on a navigation controller it is giving :
- Application tried to push a nil view controller on target
{
simpleDemoAppDelegate* delegate = [[UIApplication sharedApplication] delegate];
delegate.username = usernameText;
delegate.password = passwordText;
[delegate.secondNavController pushViewController:webView animated:YES];
}



Solution:

I had declared the webView variable in header file but not initialized the weView variable:

Corrected Code:

{
simpleDemoAppDelegate* delegate = [[UIApplication sharedApplication] delegate];
delegate.username = usernameText;
delegate.password = passwordText;
webView = [[WebViewController alloc]init];
[delegate.secondNavController pushViewController:webView animated:YES];
}


And this "animated:YES" is fooking important!

Otherwise you will get a pushViewController:]: unrecognized selector sent to instance error.

No comments:

Post a Comment