微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

显示向上箭头按钮快速向下滚动

如何解决显示向上箭头按钮快速向下滚动

当我在 tableview 中向下滚动时如何在屏幕右下角显示向上箭头按钮,当我点击向上箭头按钮时,它应该移动到上方/向上

@IBOutlet weak var tblAllRest: UITableView!
@IBOutlet weak var ScrollViewMain: UIScrollView!
@IBOutlet weak var vwAllRestaurantMain: UIView!
var isRestaurantList = true
var searchText = ""
var page = 1
var type = "All"
var arrayAllRest : [HomeRestaurantModel] = []
    func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
        let scrollViewHeight = Float(scrollView.frame.size.height)
        let scrollContentSizeHeight = Float(scrollView.contentSize.height)
        let scrollOffset = Float(scrollView.contentOffset.y)
        if scrollOffset == 0 {
            // then we are at the top
            
        }else if Int(scrollOffset + scrollViewHeight) >= Int(scrollContentSizeHeight-100) {
            // scroll to down side
            if scrollView == self.tblAllRest{
            self.ScrollViewMain.setContentOffset(.zero,animated: true)
        }
            if ScrollViewMain.convert(tblAllRest.frame,from: vwAllRestaurantMain).origin.y > ScrollViewMain.contentOffset.y + (56*kHeightAspectRasio){
                self.tblAllRest.isScrollEnabled = false
            }
            else if self.isRestaurantList{
                self.tblAllRest.isScrollEnabled = true
                self.page += 1
                GFunctions.shared.APICallRestaurantListByType(tbl : self.tblAllRest,page: self.page.description,is_featured: self.type,search: self.searchText,completion: { (complete,arrayRest) in
                    if complete{
                        self.arrayAllRest += arrayRest
                    }
                    self.tblAllRest.reloadData()
                })
            }
        }
    } 

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。