After creating the view in his Storyboard and the archives Viewcontroller, you make a bond between these two, there at Storyboard, select the bar Utilities > Identity inspector and inform the Viewcontroller, which in my example I called MinhaWebViewController
:
Go back to the implementation file (.m), and just below the @interface
declared the outlet:
@property (nonatomic, weak) IBOutlet UIWebView *webView;
Realize that for now this outlet has no link at all (note the small circle next to without filling):
To make that bond, go to Storyboard, with the key control pressed, drag the yellow icon to your UIWebView
and select the previously created property:
Now you can go back in the implementation file (.m) and note that the little circle is now filled:
You can also check when selecting your UIWebView
in the Storyboard and in Utilities > Connections inspector. There is a connection inserted for this outlet:
Ready, just do your implementation to load the URL:
NSString *fullURL = @"http://conecode.com";
NSURL *url = [NSURL URLWithString:fullURL];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[_webView loadRequest:requestObj];
If you still want the whole project, I made it available on Drive for the time being.
The code to load Webview is correct. Probably the problem is in the creation of Webview. How are you creating it (nib, storyboard, ...)? Posting the full code would facilitate identification of the problem.
– Rafael Leão
I just dragged the webview to the storyboard and declared it on @Property
– War Lock
First check that the property has been declared as Iboutlet: @Property(Weak, nonatomic) Iboutlet Uiwebview *webView. Then check the storyboard connection with the code. Right-click on the view and see if there is an Outlet for this property.
– Rafael Leão
Hello, when seeing the outlet, nothing appears, then I click on add, and a view appears, but I did not understand, still remains blank
– War Lock
To clarify what may seem obvious, but only to awaken awareness. You stated the
ViewController
as your screen controller in the storyboard?– Gian
I don’t understand , how I see it?
– War Lock
Is there any way someone could create an example project with a webview and pass me? I would be very grateful
– War Lock