2017-09-11 107 views
0

我試圖做一個拉來刷新WKWebView。當我嘗試拉和刷新,我得到這個錯誤:'NSInvalidArgumentException', reason: '-[GoldenVillage.AvailabilityViewController mymethodforref:]: unrecognized selector sent to instance 0x111d18e50'拉WKWebview上刷新

如何解決它?

我的代碼在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 
} 
+0

,而不是'選擇(( 「mymethodforref:」)''嘗試#selector(mymethodforref (刷新:))' – 3stud1ant3

+0

@ 3stud1ant3它的工作!我可以問另一個問題?如何改變刷新控制器的位置?我的廣告代表答案的位置代碼,但我得到錯誤。如何將CGReactMake轉換爲CGReact? –

+0

查看我的回答 – 3stud1ant3

回答

1

代替

Selector(("mymethodforref:") 

嘗試

#selector(mymethodforref(refresh:))