在单击Tableview Cell上使用哪种方法更新Rest Api数据

问题描述 投票:0回答:1

我在Tableview中有休息Api数据显示,我想在同一个ViewController中使用不同的数据并使用Rest api在Tableview上重新加载数据,我想知道如何在同一页面上更新我的数据后点击不同的类别和子类别。

this image for menu of category and sub category

This is my viewController

ios swift3 tableview
1个回答
0
投票

你可以这样做

var page:Int = 0
var isPageRefreshing:Bool = false

    override func viewDidLoad() {
     super.viewDidLoad()
     // Do any additional setup after loading the view.
     YourApi(page1: 0)
     }

   func scrollViewDidScroll(_ scrollView: UIScrollView) {
        if(self.mytableview.contentOffset.y >= 
        (self.mytableview.contentSize.height - 
        self.mytableview.bounds.size.height)) {
            if(isPageRefreshing==false) {
                 isPageRefreshing=true
                 print(page)
                 page = page + 1
                 YourApi(page1: page)
        }
    }
}

在你的api代码中

func YourApi(page1 :Int) {
    let mypage = String(page1)
    let Request: String = String.init(format:"apiName/%@",mypage)
    print(Request)
 }
© www.soinside.com 2019 - 2024. All rights reserved.