Add buttons under a tableview

前端 未结 3 1133
感动是毒
感动是毒 2021-02-11 02:27

I\'m trying to create a view programmatically. The result that i want to have is a scroll view with a tableview inside. And under this table view i want to add some buttons

3条回答
  •  你的背包
    2021-02-11 03:07

    One thing to note is that UITableView is a subclass of UIScrollView so you will likely have to manage the size of the UITableView differently than if you were just letting it do the scrolling.

    Your code appears to be setting the tableView and the deconnectButton to the same size and that size is the size of the scrollView superview. I would expect this to have the affect of the tableView obscuring the button.

    Based on what you describe it sounds like you should calculate what the size of the table needs to be based on its contents and then set its frame accordingly. Then set the frame of the button to be just below that. Also, you will need to set the size of the scrollView using its contentSize property. The problem in this scenario is that you will have to always be keeping the size of the scrollView and the position of the button in sync with the size of the tableView.

    You might investigate making the last row in the table the button and eliminating the outer scroll view. In the end that may result in less code.

提交回复
热议问题