我在iOS 6中看到了UIRefreshControl,我的问题是如果可以通过拉下来刷新WebView,而不是像邮件一样弹出呢?
代码我用的是rabih是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];
- }