0
我試圖將UILabel pageTitle更改爲顯示在UIWebView上的頁面的標題。我沒有回覆警告或錯誤,只是沒有改變。從已加載的WebView獲取頁面標題
ViewController.h
@interface ViewController : UIViewController <UITextFieldDelegate, UIWebViewDelegate, UIActionSheetDelegate> {
UIWebView *_webView;
UILabel *_pageTitle;
}
@property (nonatomic, retain) IBOutlet UIWebView *webView;
@property (nonatomic, retain) IBOutlet UILabel *pageTitle;
@end
ViewController.m
- (void)webViewDidFinishLoad:(UIWebView *)webView {
self.pageTitle.text = [_webView stringByEvaluatingJavaScriptFromString:@"document.title"];
[_webView setDelegate:self];
}
IB的截圖
您記得您的UIWebView的委託設置爲視圖控制器,這樣webViewDidFinishLoad:被稱爲? – simonbs