I saw the UIRefreshControl in iOS 6 and my question is if it is possible to refresh a WebView by pulling it down and than let it pop up like in mail? Code I used rabih is the We
Extending @umut-can-köseali answer to have better control of the UIRefreshControl when refresh ends:
- (void)viewDidLoad {
[super viewDidLoad];
_refreshControl = [[UIRefreshControl alloc] init];
[_refreshControl addTarget:self action:@selector(handleWebViewRefresh:) forControlEvents:UIControlEventValueChanged];
[self.webView.scrollView addSubview:_refreshControl]; //<- this is point to use. Add "scrollView" property.
}
- (void)webView:(UIWebView *)_webView didFailLoadWithError:(NSError *)error {
[_refreshControl endRefreshing];
}
- (void)webViewDidFinishLoad:(UIWebView *)_webView {
NSString *navigatorUrl = _webView.request.URL.absoluteString;
if( navigatorUrl && ![navigatorUrl isEqualToString:@""]) {
NSString *host=_webView.request.URL.host;
NSString *path=_webView.request.URL.path;
[_refreshControl endRefreshing];
}
}