Tôi muốn tải các trang HTML bằng WkWebView và tôi muốn hiển thị trang ngay sau khi tải xong. Miễn là nó đang tải tôi muốn hiển thị một chỉ số hoạt động trên một View trống. Tôi tạo hai chế độ xem là một tệp tải và một wkWebView. Trong khi trang đang tải tôi thêm vào VC làm subview loadView và sau khi tôi muốn loại bỏ loadingView và thêm wkWebView. Đây là mã của tôi:Làm thế nào để kiểm tra xem WkWebView có tải xong trong Objective-C không?
[self addSubview:_loadingView];
_wkWebView = [[WKWebView alloc] initWithFrame:self.frame];
_wkWebView.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y, self.frame.size.width, self.frame.size.height);
//Send a request to wkUrlconnection
NSURL *wkUrl = [NSURL URLWithString:self.wkUrlString];
NSURLRequest *wkRequest = [NSURLRequest requestWithURL:wkUrl];
//Here I want to check if it's loaded and then remove loadingView and add wkWebView
[_wkWebView loadRequest:wkRequest];
[self.loadingView removeFromSuperview];
[self addSubview:_wkWebView];
Ai đó có thể chỉ cho tôi cách kiểm tra khi đang tải và làm mới VC? Cảm ơn bạn cho câu trả lời của bạn.
Bạn đã xem [delegate] (https://developer.apple.com/library/ios/documentation/General/Conceptual/CocoaEncyclopedia/DelegatesandDataSources/DelegatesandDataSources.html) -pattern và cách nó được sử dụng với ' navigationDelegate' thuộc tính trên 'WKWebView'? – Mats
Cảm ơn Mats. Tôi cần cái này. – faklyasgy