ios – 对UIWebView使用UIRefreshControl

我在iOS 6中看到了UIRefreshControl,我的问题是如果可以通过拉下来刷新WebView,而不是像邮件一样弹出呢?
代码我用的是rabih是WebView:
UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init];
    [refreshControl addTarget:self action:@selector(handleRefresh:) forControlEvents:UIControlEventValueChanged];
    [rabih addSubview:rabih];

解决方法

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

相关文章

UITabBarController 是 iOS 中用于管理和显示选项卡界面的一...
UITableView的重用机制避免了频繁创建和销毁单元格的开销,使...
Objective-C中,类的实例变量(instance variables)和属性(...
从内存管理的角度来看,block可以作为方法的传入参数是因为b...
WKWebView 是 iOS 开发中用于显示网页内容的组件,它是在 iO...
OC中常用的多线程编程技术: 1. NSThread NSThread是Objecti...