CodeWeed
CodeWeed

Reputation: 1071

creating a UIWebView dynamically on a UIViewController

I need to fill UIViewController with UIWebView dynamically. I am using the UIWebviewController to load automatically on iPhone and iPad. I am using a UINavigationController to push the UIViewController on to the screen.

Here is what I had done

in the view controller code ( in *.h )

@property (weak, nonatomic) IBOutlet UIWebView *webview;

( in *.m file )

@synthesize webview;

( in viewDidLoaded method )

self.webview = [[UIWebView alloc] initWithFrame:self.view.bounds];
self.webview.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
self.webview.delegate = self;
[self.view addSubview:self.webview];

I am pushing the viewcontroller like this

CommonViewController *commonController = [CommonViewController alloc] initWithNibName:nil bundle:nil];
[self.navigationController pushViewController:commonController animated:YES];

I am getting exception

* Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "CommonViewController" nib but the view outlet was not set.' *

can anyone tell me what is causing the exception. I have added the webview to view, I am not sure what to do next !!!

Upvotes: 0

Views: 1315

Answers (1)

lakshmen
lakshmen

Reputation: 29064

Read this post: Loaded nib but the view outlet was not set - new to InterfaceBuilder

You forgot to do this step: You should see "outlets" with "view" under it. Drag the circle next to it over to the "view" icon on the left bar (bottom one, looks like a white square with a thick gray outline

Hope this helps you...

Upvotes: 1

Related Questions