1

I created an app with Swift 3 and Xcode 8.1. I have a UITableview and a UIView above it that shows and hides by clicking on a button in it. When the UIView appears, the last cell of UITableview does not show completely.

I use following code in button:

func filterShowHide ()
{
    if !isShown
    {
        filterImage.image = UIImage(named: "ME-Filter-re")
        self.filterView.isHidden = false
        self.tableViewTop.constant = 0
        // tableViewHeight.constant =  tableViewHeight.constant * 1.5
        isShown = true
    }
    else
    {
        filterImage.image = UIImage(named: "ME-Filter")
        self.tableViewTop.constant = -(self.HeaderView.frame.height) + self.filterBTN.frame.size.height
        self.filterView.isHidden = true
        isShown = false
        // tableViewHeight.constant =  tableViewHeight.constant / 1.5
    }
    UIView.animate(withDuration: 0.25) {
        self.view.layoutIfNeeded()
    }
}

For more details here's the screenshot of:

Before clicking and After clicking

Before clicking After clicking

How can I show the last cell completely?

rmaddy
  • 314,917
  • 42
  • 532
  • 579
  • You are decreasing the table height and cells are bigger in height. It is making the tableview scrollable. right..?? – Amit Aug 22 '17 at 16:11
  • It looks like your tableview is not scrolling in both the cases. Am I right? – Aditya Srivastava Aug 22 '17 at 16:16
  • @Amit No, the Height of tableview not changed, i.e, I couldn't change it. I try many methods to do that but it's not working. When I scroll to the last cell, it's not appears entirely. such in screenshots. –  Aug 22 '17 at 16:17
  • @AdityaSrivastava No, It's scrolling but last cell not appears entirely. –  Aug 22 '17 at 16:18
  • Have you set the bottom constraint for the last item(notes button) in the cell. – Aditya Srivastava Aug 22 '17 at 16:21
  • @AdityaSrivastava, Actually, The last item it's a label which appears as a line. It's have a bottom constraint. –  Aug 22 '17 at 16:27
  • If you want variable row heights as per content, refer this link https://stackoverflow.com/questions/18746929/using-auto-layout-in-uitableview-for-dynamic-cell-layouts-variable-row-heights – Rahul Kumar Aug 22 '17 at 17:15

1 Answers1

0

I think the problem is your tableview height is still the same and it gets pushed down as you update the top constraint.

You should set the table view bottom constraint to bottom of its super view or you can update tableView.contentInset.top with the values you are using for self.tableViewTop.constant

HMHero
  • 2,333
  • 19
  • 11