在 WebVIew 中加载请求时应用程序崩溃 - Objective C
App is crashing while loading request in UIWebVIew - ObjectiveC
我正在将 URL 加载到我的 webView
,但刚开始 loadRequest
我的应用程序就崩溃了。
我的 WebView
在带有 XIB
的自定义 UIView
Class 中,我正在添加这样的视图:
WebViewContainer *webViewContainer = [[[NSBundle mainBundle] loadNibNamed:@"WebViewContainer" owner:nil options:nil] firstObject];
[webViewContainer startLoadingURL:kPersonalWebsiteURL];
webViewContainer.frame = CGRectMake(0, 0, kScreenWidth, kScreenHeight);
[self.view addSubview:webViewContainer];
我的startLoadingURL
方法:
- (void)startLoadingURL:(NSString *)url
{
NSURL *urlToLoad = [NSURL URLWithString:url];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:urlToLoad];
[self.webView loadRequest:requestObj];
}
这是界面生成器配置:
这是错误消息我只收到此错误消息而没有收到任何日志。
尝试重新键入 nil
至 self
作为所有者参数。所以你可能需要更换:
WebViewContainer *webViewContainer = [[[NSBundle mainBundle] loadNibNamed:@"WebViewContainer" owner:nil options:nil]
和
WebViewContainer *webViewContainer = [[[NSBundle mainBundle] loadNibNamed:@"WebViewContainer" owner:self options:nil]
我正在将 URL 加载到我的 webView
,但刚开始 loadRequest
我的应用程序就崩溃了。
我的 WebView
在带有 XIB
的自定义 UIView
Class 中,我正在添加这样的视图:
WebViewContainer *webViewContainer = [[[NSBundle mainBundle] loadNibNamed:@"WebViewContainer" owner:nil options:nil] firstObject];
[webViewContainer startLoadingURL:kPersonalWebsiteURL];
webViewContainer.frame = CGRectMake(0, 0, kScreenWidth, kScreenHeight);
[self.view addSubview:webViewContainer];
我的startLoadingURL
方法:
- (void)startLoadingURL:(NSString *)url
{
NSURL *urlToLoad = [NSURL URLWithString:url];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:urlToLoad];
[self.webView loadRequest:requestObj];
}
这是界面生成器配置:
这是错误消息我只收到此错误消息而没有收到任何日志。
尝试重新键入 nil
至 self
作为所有者参数。所以你可能需要更换:
WebViewContainer *webViewContainer = [[[NSBundle mainBundle] loadNibNamed:@"WebViewContainer" owner:nil options:nil]
和
WebViewContainer *webViewContainer = [[[NSBundle mainBundle] loadNibNamed:@"WebViewContainer" owner:self options:nil]