在WKWebview上刷新

时间:2017-09-11 08:09:39

标签: swift wkwebview

我试图在WKWebView上进行刷新。当我尝试拉动和刷新时,我收到此错误:'NSInvalidArgumentException', reason: '-[GoldenVillage.AvailabilityViewController mymethodforref:]: unrecognized selector sent to instance 0x111d18e50'

如何解决?

我在viewDidAppear中的代码:

self.availabilityWebview = WKWebView(
     frame: self.containerView.bounds,
     configuration: config
)
self.view = self.availabilityWebview!
refController.bounds = CGRectMake(0, 50, refController.bounds.size.width, refController.bounds.size.height) 
refController.addTarget(self, action: Selector(("mymethodforref:")), for: UIControlEvents.valueChanged)
refController.attributedTitle = NSAttributedString(string: "Pull to refresh")
availabilityWebview?.scrollView.addSubview(refController)

self.noNetwork.text! = ""
if let crew = user!["crew"] as? [String:Any], let crewID = crew["crew_id"] as? String {

let url = URL(string: "http://ec2-52-221-231-3.ap-southeast-1.compute.amazonaws.com/gv/available-schedule_3.php?id=\(crewID)")
self.availabilityWebview!.load(URLRequest(url:url!))


func mymethodforref(refresh:UIRefreshControl){
    availabilityWebview?.reload()
    refController.endRefreshing()
}
func webViewDidFinishLoad(_ webView: UIWebView) {
    UIApplication.shared.isNetworkActivityIndicatorVisible = false
}

func webViewDidStartLoad(_ webView: UIWebView) {
    UIApplication.shared.isNetworkActivityIndicatorVisible = true
}

1 个答案:

答案 0 :(得分:1)

而不是

Selector(("mymethodforref:")

#selector(mymethodforref(refresh:))