I have created one viewcontroller with UIWebView and trying to add as subview to another view controller. That causes to crash which sends bad request error .
The code Controller that contains WebView is as follow:
@interface WebViewController : UIViewController
@end
@interface WebViewController () <UIWebViewDelegate>
{
IBOutlet UIWebView *webView;
}
@end
@implementation WebViewController
- (void)viewDidLoad {
[super viewDidLoad];
webView.delegate = self;
NSString *str = [NSString stringWithFormat:@"<html><body>This is html text</body></html>"];
[webView loadHTMLString:str baseURL:nil];
// Do any additional setup after loading the view.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType{
return YES;
}
- (void)webViewDidStartLoad:(UIWebView *)webView{
}
- (void)webViewDidFinishLoad:(UIWebView *)webView{
}
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error{
}
Code that implements the WebViewController is :
WebViewController *obj = [self.storyboard instantiateViewControllerWithIdentifier:@"webView"];
[self.view addSubview:obj.view];
Aucun commentaire:
Enregistrer un commentaire