我在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]; }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。