Load Webview in Objective c

Asked

Viewed 168 times

5

I set up a Builder interface to load a webview, with . h, . m and .xib. In a side menu, when clicking on an option, I need to call this webview. Running the application, clicking on this option returns me the error "Thread 1: Signal SIGABRT" in main. m.

.h file:

#ifndef WebViewCadastro_h
#define WebViewCadastro_h


#endif /* WebViewCadastro_h */


#import <UIKit/UIKit.h>

@interface WebViewCadastro : UIViewController{
    IBOutlet UIWebView *webView;
}

@property (nonatomic, retain) UIWebView *webView;

@end

.m file:

#import "WebViewCadastro.h"

@implementation WebViewCadastro

-(void)viewDidLoad{
    [super viewDidLoad];
    NSString *urlAddress = @"https://www.google.com";
    NSURL *url = [NSURL URLWithString:urlAddress];
    NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
    [webView loadRequest:requestObj];
}

@end

.xib file:

.xib

Nib call:

if([SINControler userLogado] == nil){
                [SINControler setUserLogado:nil];

 WebViewCadastro *curriculocontroller = [[WebViewCadastro alloc]
                    initWithNibName:@"WebViewCadastro" bundle:nil];

                UINavigationController *navigationController = self.menuContainerViewController.centerViewController;
                NSArray *controllers = [NSArray arrayWithObject:curriculocontroller];
                navigationController.viewControllers = controllers;
                [self.menuContainerViewController setMenuState:MFSideMenuStateClosed];
                [self.menuContainerViewController setLeftMenuViewController:nil];

Am I making an obvious mistake? Is there any solution available? Thank you.

1 answer

4


Missing connect the interface 'view' outlet with File’s Owner. The same way you did with 'webView'.

  • Thank you. Now it opens the webview, but does not load the google page. Any suggestions?

  • It’s probably because of the App Transport Security (ATS) settings. https://answall.com/questions/91156/webview-em-ios-n%C3%A3o-est%C3%A1-accessing-some-sites/91170#91170

Browser other questions tagged

You are not signed in. Login or sign up in order to post.