加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

swift2.x UIRefreshControl() 下拉刷新

发布时间:2020-12-14 06:41:27 所属栏目:百科 来源:网络整理
导读:例如对UIwebview添加下拉刷新 声明下拉刷新控件 var refreshControl = UIRefreshControl () // 给 webView 添加下拉刷新 refreshControl . addTarget ( self ,action: "refreshPage" ,forControlEvents: .ValueChanged) refreshControl . attributedTitle =

例如对UIwebview添加下拉刷新

声明下拉刷新控件

var refreshControl =UIRefreshControl()

//webView添加下拉刷新

refreshControl.addTarget(self,action:"refreshPage",forControlEvents: .ValueChanged)

refreshControl.attributedTitle =NSAttributedString(string:"Refresh")

webview.scrollView.addSubview(refreshControl)//关键代码

注意:UIWebView必须保留拖动效果,默认webview.scrollView.bounces 是true,所以不用刻意设置为true。这里是提醒不要设置为false了

//webview.scrollView.bounces = true

//下拉刷新执行的方法

func refreshPage() {

//print("Refreshing...")

webview.reload()

}


加载完成停止刷新调用:

refreshControl.endRefreshing()

更多下拉上拉刷新请参考:http://www.wtoutiao.com/p/3famTu3.html

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读