我正在尝试在加载网站的UIWebView
上实现下拉刷新功能。 UIWebView
的代码非常简单。
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var WebView: UIWebView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let URL = NSURL(string: "https://the url/")
WebView.loadRequest(NSURLRequest(URL: URL!))
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
有没有任何示例,因为无论我搜索什么,我只找到了在表视图上进行下拉刷新的示例,而我不确定它是否也适用于这个。
谢谢。
更新1. 根据Sohil的建议,代码如下:
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var WebView: UIWebView!
@IBOutlet weak var scrollView: UIScrollView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let URL = NSURL(string: "https://iremember.gr/")
WebView.loadRequest(NSURLRequest(URL: URL!))
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
func scrollViewWillEndDragging(scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) {
if (scrollView.contentOffset.y < 0){
//reach top
print("Reach Top")
WebView.reload()
}
else {
print("nothing")
}
}
}
}
但是当我尝试重新加载它时,它甚至不会打印出“nothing”。
didReceiveMemoryWarning
的实现中? - jrturton