简体   繁体   中英

Swift UITableView On Reload Data

I have some code I want to run on the function onReload of my UITableView. Basically for now I just want to print how many items there are in an array. Later on I will want to display or not display a view depending on how many items there is.

So I want this code to run whenever the UITableView refreshes or reloads or anything like that.

How can I achieve that?

override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    //dataArray is your data array
    // > 10 is your condition
    if dataArray.count >10{
        return 0
    }else{
        return dataArray.count
    }

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM