ios – 对UIWebView使用UIRefreshControl

前端之家收集整理的这篇文章主要介绍了ios – 对UIWebView使用UIRefreshControl前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我在iOS 6中看到了UIRefreshControl,我的问题是如果可以通过拉下来刷新WebView,而不是像邮件一样弹出呢?
代码我用的是rabih是WebView: @H_301_3@UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init]; [refreshControl addTarget:self action:@selector(handleRefresh:) forControlEvents:UIControlEventValueChanged]; [rabih addSubview:rabih];

解决方法

这是你如何使用下拉刷新UIWebview: @H_301_3@- (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]; }

猜你在找的iOS相关文章