gpt4 book ai didi

swift - WKWebview 拉动刷新

转载 作者:行者123 更新时间:2023-11-28 15:20:06 25 4
gpt4 key购买 nike

我正在尝试在 WKWebView 上拉动刷新。当我尝试拉取和刷新时,出现此错误:'NSInvalidArgumentException',原因:'-[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
}

最佳答案

代替

Selector(("mymethodforref:")

尝试

#selector(mymethodforref(refresh:))

关于swift - WKWebview 拉动刷新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46150979/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com