Search code examples
htmliosobjective-cuiwebview

I am trying to Load html string into a webview. But the webview shows a white blank colour on run time


I am trying to Load html string into a webview. But the webview shows a white blank colour on run time. added the UIWebViewDelegate and declare object like this.

@property (strong, nonatomic) IBOutlet UIWebView *aboutWebView;

but still having the same issue.

- (void)viewDidLoad {
    [super viewDidLoad];
    [[self navigationController] setNavigationBarHidden:YES animated:YES];
    [_aboutWebView setDelegate:self];

    [self loadWebView];
    // Do any additional setup after loading the view.
}
-(void)loadWebView{
    _aboutWebView= [[UIWebView alloc]init];
    _aboutWebView.backgroundColor= [UIColor blueColor];
    NSString *embedHTML= @"html Code";

    [_aboutWebView loadHTMLString: embedHTML baseURL: nil];

}

Solution

  • Please remove the below line from your code.It works for you.

    _aboutWebView= [[UIWebView alloc]init];