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
This is how you can use pull down to refresh on UIWebview:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
// Make webView a delegate to itself
// I am going to add URL information
NSString *fullURL = @"http://www.umutcankoseali.com/";
NSURL *url = [NSURL URLWithString:fullURL];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
_webView.delegate = (id)self;
[_webView loadRequest:requestObj];
UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init];
[refreshControl addTarget:self action:@selector(handleRefresh:) forControlEvents:UIControlEventValueChanged];
[_webView.scrollView addSubview:refreshControl]; //<- this is point to use. Add "scrollView" property.
}
-(void)handleRefresh:(UIRefreshControl *)refresh {
// Reload my data
NSString *fullURL = @"http://www.umutcankoseali.com/";
NSURL *url = [NSURL URLWithString:fullURL];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[_webView loadRequest:requestObj];
[refresh endRefreshing];
}