how to hide empty rows in a UITableView and change the height of the Uitableview based on non-empty rows

前端 未结 11 1865
离开以前
离开以前 2021-01-30 05:06

I have couple of problems with my UITableView.

  1. When I add a UITableview on my page, by default it brings up some fixed number of rows,

11条回答
  •  孤独总比滥情好
    2021-01-30 05:34

    For Swift:

    override func viewWillAppear(animated: Bool) {
        self.tableView.tableFooterView = UIView(frame: CGRect.zeroRect)
    
    // OR 
    
        self.tableView.tableFooterView = UIView()
    }
    

    For C#: (Please don't forget to add using CoreGraphics; )

    public override void ViewWillAppear(bool animated)
    {
        base.ViewWillAppear(animated);
        this.sampleTableview.TableFooterView = new UIView(frame: CGRect.Empty);
    }
    

提交回复
热议问题