swift - Pull to refresh on WKWebview -
i'm trying make pull refresh on wkwebview. when try pull , refresh, error:'nsinvalidargumentexception', reason: '-[goldenvillage.availabilityviewcontroller mymethodforref:]: unrecognized selector sent instance 0x111d18e50'
how fix it?
my code in 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 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 }
instead of
selector(("mymethodforref:") try
#selector(mymethodforref(refresh:))
Comments
Post a Comment