UITableViewController not scrolling view when keyboard appears

会有一股神秘感。 提交于 2019-12-02 23:06:23
LJ Wilson

Make sure that if you are overriding viewWillAppear that you call

[super viewWillAppear:animated];

If you don't, the Scroll View will not scroll up properly.

Swift

super.viewWillAppear(animated)

I found non of these answers to be correct. After a while, I notice that if you push a controller it won't work ... but if you present it modally.. the table will automatically scroll to the used textfield.

Hope that saves time and stress to anyone.

I ran into this issue myself. I just converted my view controller from a UIViewController to a UITableViewController in addition to adding the [super viewWillAppear:animated]; call, you will need to remove these lines:

[self.tableView setDataSource:self]; [self.tableView setDelegate:self];

As they are no longer needed and setDelegate interferes with the keyboard scrolling behavior.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!