0

enter image description here

Hi I'm trying to resize tableview's height after hidden indicatorView.

        self.tableView.reloadData()
        self.refresher.endRefreshing()
        self.indicator.stopAnimating()

        self.indicatorView.isHidden = true

When I set indicatorView as hidden but TableView's height still has space of indicatorView's height.

Ahmad F
  • 30,560
  • 17
  • 97
  • 143
Shawn Baek
  • 1,928
  • 3
  • 20
  • 34

2 Answers2

1

Somehow, You need to implement tableView(_:heightForRowAt:). For example:

func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
    // pseudo:
    /*
     if a condition related to hide the indicator (for example response from calling an api to get some data) is true, retrun -for example 100-, else (the response has not been called yet) retrun another value.
     */
}

You can also check the indexPath.row for chaning a specific row height:

func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
    // check if it is the second row:
    if indexPath.row == 1 {

    }
}

So, after calling self.tableView.reloadData() it should be called and assign the new height for the row.

Hope this helped.

Ahmad F
  • 30,560
  • 17
  • 97
  • 143
1

Embed tableView and indicatorView in a stackview.

Like in this answer, but with Vertical Axis.

Community
  • 1
  • 1
shallowThought
  • 19,212
  • 9
  • 65
  • 112