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

问题描述

当我在 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 (将#修改为@)