gpt4 book ai didi

ios - UIWebview 内容不可见

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:04:41 24 4
gpt4 key购买 nike

我有一个 UIWebview 作为自定义 View 的 subview 。我已经将 XIB 用于自定义 View 。所以层次结构如下:-

ViewController.view -(subview)> SettingsCustomView -(subview)> TermsCustomView -(subview)> UIWebview(在 XIB 中)。

我已经完美地连接了委托(delegate)方法和 Outlet。一切都按应有的方式加载和发生,甚至可以完美无误地调用方法。只缺少一件事,webview 的内容。好像内容正在加载但不可见。

我做了这些,但它们都没有显示内容,尽管它加载了内容:-

NSString *htmlFile = [[NSBundle mainBundle] pathForResource:@"terms" ofType:@"html"];
NSString* htmlString = [NSString stringWithContentsOfFile:htmlFile encoding:NSUTF8StringEncoding error:nil];
[self.termWebView loadHTMLString:htmlString baseURL:nil];

我也试过这个:-

[self.termWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.google.com"]]];

在第一种情况下,所有调用 html 字符串的委托(delegate)方法都是完美的。只是内容好像看不见。

在此先感谢您的帮助。

最佳答案

最后我通过添加 UIWebview 的委托(delegate)方法并返回 TRUE 解决了这个问题,如下所示:

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request   navigationType:(UIWebViewNavigationType)navigationType {
return YES;
}

关于ios - UIWebview 内容不可见,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24833686/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com