【发布时间】:2011-12-13 08:38:34
【问题描述】:
我有一个简单的 IB 视图,其中只包含一个 UIWebView 和一个 UIButton。
webView 被保留,已连接,而不是 nil,委托属性 os 也已连接,Controller 符合 UIWebViewDelegate 并在 .h 中设置。
在 ViewDidLoad 中,我使用[self.webView loadHTMLString:htmlContent baseURL:nil];
内容加载,但从未触发webViewDidFinishLoad、didFailLoadWithError、webViewDidStartLoad。
我如何知道我的内容何时完成加载,因为它需要很短的时间,但仍然需要一段时间才能加载(例如,我需要在展示的这段时间内做一些事情不显示按钮)?
@interface MyController : UIViewController <UIWebViewDelegate> {
UIWebView* webView;
}
@property (nonatomic, retain) IBOutlet UIWebView* webView;
@end
@implementation MyController
@synthesize webView;
- (void)viewDidLoad
{
[super viewDidLoad];
constructing the htmlString
id a = self.webView.delegate; // for debug
[self.webView loadHTMLString:htmlContent baseURL:nil];
}
@end
编辑: 我已经删除了整个 XIB 并从 scrathc 构建它:没有问题了。 IB有时很烂。
【问题讨论】:
-
htmlcontent 不是 nil 吗?显示如何加载的代码。
-
是否应该调用 shouldStartLoadWithRequest ?
-
@logancautrell : shouldStartLoadWithRequest 没有被调用
-
尝试删除 nib 中的 uiwebview 并将代理和插座重置为它。
-
我可以看到代理是 nil(在 viewDidLoad 中),但它连接到 IB。我一次又一次地尝试连接它,但这并没有改变任何东西。
标签: iphone cocoa-touch uiwebview properties interface-builder