简体   繁体   中英

Let tableview's last cell scroll to half way up the screen

I have a tableview with custom cells. Each cell has a UITextfield. When the last cell's textfield is clicked, the keyboard pops up and covers it and the table view won't scroll up any further. Is there a property of UITableview that can be set so that the last cell can scroll to half way up the screen?

Thanks in advance

There are a two ways to approach this (that I can think about off the top of my head):

  • You can use the tableFooterView property of UITableView to set an arbitrary, empty view to be about half the size of your table.
  • You can add empty cells to the bottom of your table

Both of these approaches will accomplish roughly the same thing, but using the tableFooterView property is probably your best bet.

see Making a UITableView scroll when text field is selected for a list of solution..

Also basing your view controller from UITableViewController (since you say its a table) will provide all this functionality automatically!

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